-#
+# dns based ad/abuse domain blocking
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=adblock
-PKG_VERSION:=4.2.7
-PKG_RELEASE:=3
+PKG_VERSION:=4.4.0
+PKG_RELEASE:=1
PKG_LICENSE:=GPL-3.0-or-later
define Package/adblock
SECTION:=net
CATEGORY:=Network
- TITLE:=Powerful adblock script to block ad/abuse domains by using DNS
+ TITLE:=adblock blocks ad/abuse domains by using DNS
DEPENDS:=+jshn +jsonfilter +coreutils +coreutils-sort +gawk +ca-bundle +rpcd +rpcd-mod-rpcsys
PKGARCH:=all
endef
define Package/adblock/description
-Powerful adblock solution to block ad/abuse domains via dnsmasq, unbound, named, smartdns or kresd.
-The script supports many domain blacklist sites plus manual black- and whitelist overrides.
+adblock blocks ad/abuse domains via dnsmasq, unbound, named, smartdns or kresd.
+adblock supports many domain blocklist sites plus local block- and allowlist overrides.
Please see https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md for further information.
endef
define Package/adblock/conffiles
/etc/config/adblock
-/etc/adblock/adblock.whitelist
-/etc/adblock/adblock.blacklist
+/etc/adblock/adblock.allowlist
+/etc/adblock/adblock.blocklist
+/etc/adblock/adblock.custom.feeds
endef
define Build/Prepare
$(INSTALL_DIR) $(1)/etc/adblock
$(INSTALL_BIN) ./files/adblock.mail $(1)/etc/adblock
- $(INSTALL_CONF) ./files/adblock.blacklist $(1)/etc/adblock
- $(INSTALL_CONF) ./files/adblock.whitelist $(1)/etc/adblock
+ $(INSTALL_CONF) ./files/adblock.allowlist $(1)/etc/adblock
+ $(INSTALL_CONF) ./files/adblock.blocklist $(1)/etc/adblock
$(INSTALL_CONF) ./files/adblock.categories $(1)/etc/adblock
- $(INSTALL_CONF) ./files/adblock.sources $(1)/etc/adblock
- gzip -9n $(1)/etc/adblock/adblock.sources
+ $(INSTALL_CONF) ./files/adblock.feeds $(1)/etc/adblock
+ $(INSTALL_CONF) ./files/adblock.custom.feeds $(1)/etc/adblock
endef
$(eval $(call BuildPackage,adblock))
# DNS based ad/abuse domain blocking
+<a id="description"></a>
## Description
A lot of people already use adblocker plugins within their desktop browsers, but what if you are using your (smart) phone, tablet, watch or any other (wlan) gadget!? Getting rid of annoying ads, trackers and other abuse sites (like facebook) is simple: block them with your router. When the DNS server on your router receives DNS requests, you will sort out queries that ask for the resource records of ad servers and return a simple 'NXDOMAIN'. This is nothing but **N**on-e**X**istent Internet or Intranet domain name, if domain name is unable to resolved using the DNS server, a condition called the 'NXDOMAIN' occurred.
+<a id="main-features"></a>
## Main Features
-* Support of the following fully pre-configured domain blocklist sources (free for private usage, for commercial use please check their individual licenses)
+* Support of the following fully pre-configured domain blocklist feeds (free for private usage, for commercial use please check their individual licenses)
-| Source | Enabled | Size | Focus | Information |
+| Feed | Enabled | Size | Focus | Information |
| :------------------ | :-----: | :--- | :--------------- | :-------------------------------------------------------------------------------- |
| 1Hosts | | VAR | compilation | [Link](https://github.com/badmojr/1Hosts) |
| adaway | | S | mobile | [Link](https://github.com/AdAway/adaway.github.io) |
| winspy | | S | win_telemetry | [Link](https://github.com/crazy-max/WindowsSpyBlocker) |
| yoyo | | S | general | [Link](https://pgl.yoyo.org/adservers) |
-* List of supported and fully pre-configured adblock sources, already active sources are pre-selected.
- <b><em>To avoid OOM errors, please do not select too many lists!</em></b>
- List size information with the respective domain ranges as follows:
- • <b>S</b> (-10k), <b>M</b> (10k-30k) and <b>L</b> (30k-80k) should work for 128 MByte devices,
- • <b>XL</b> (80k-200k) should work for 256-512 MByte devices,
- • <b>XXL</b> (200k-) needs more RAM and Multicore support, e.g. x86 or raspberry devices.
- • <b>VAR</b> (50k-900k) variable size depending on the selection.
+* List of supported and fully pre-configured adblock sources, already active sources are pre-selected.
+ <b><em>To avoid OOM errors, please do not select too many lists!</em></b>
+ List size information with the respective domain ranges as follows:
+ • <b>S</b> (-10k), <b>M</b> (10k-30k) and <b>L</b> (30k-80k) should work for 128 MByte devices
+ • <b>XL</b> (80k-200k) should work for 256-512 MByte devices
+ • <b>XXL</b> (200k-) needs more RAM and Multicore support, e.g. x86 or raspberry devices
+ • <b>VAR</b> (50k-900k) variable size depending on the selection
* Zero-conf like automatic installation & setup, usually no manual changes needed
* Simple but yet powerful adblock engine: adblock does not use error prone external iptables rulesets, http pixel server instances and things like that
* Supports six different DNS backend formats: dnsmasq, unbound, named (bind), kresd, smartdns or raw (e.g. used by dnscrypt-proxy)
-* Supports four different SSL-enabled download utilities: uclient-fetch, wget, curl or aria2c
-* Supports SafeSearch for google, bing, duckduckgo, yandex, youtube and pixabay
+* Supports three different SSL-enabled download utilities: uclient-fetch, full wget or curl
+* Supports SafeSearch for google, bing, brave, duckduckgo, yandex, youtube and pixabay
* Supports RPZ-trigger 'RPZ-CLIENT-IP' to always allow/deny certain DNS clients based on their IP address (currently only supported by bind dns backend)
* Fast downloads & list processing as they are handled in parallel running background jobs with multicore support
+* The download engine supports ETAG headers to download only updated feeds
* Supports a wide range of router modes, even AP modes are supported
* Full IPv4 and IPv6 support
* Provides top level domain compression ('tld compression'), this feature removes thousands of needless host entries from the blocklist and lowers the memory footprint for the DNS backend
-* Provides a 'DNS File Reset', where the generated DNS blocklist file will be purged after DNS backend loading to save storage space
-* Source parsing by fast & flexible regex rulesets, all rules and source information are placed in an external/compredd JSON file ('/etc/adblock/adblock.sources.gz')
+* Provides a 'DNS Shift', where the generated final DNS blocklist is moved to the backup directory and only a soft link to this file is set in memory. As long as your backup directory is located on an external drive, you should activate this option to save disk space.
+* Source parsing by fast & flexible regex rulesets, all rules and feed information are placed in an external JSON file ('/etc/adblock/adblock.feeds')
* Overall duplicate removal in generated blocklist file 'adb_list.overall'
-* Additional local blacklist for manual overrides, located in '/etc/adblock/adblock.blacklist'
-* Additional local whitelist for manual overrides, located in '/etc/adblock/adblock.whitelist'
+* Additional local blocklist for manual overrides, located in '/etc/adblock/adblock.blocklist'
+* Additional local allowlist for manual overrides, located in '/etc/adblock/adblock.allowlist'
* Quality checks during blocklist update to ensure a reliable DNS backend service
* Minimal status & error logging to syslog, enable debug logging to receive more output
-* Procd based init system support ('start', 'stop', 'restart', 'reload', 'enable', 'disable', 'running', 'status', 'suspend', 'resume', 'query', 'report', 'list', 'timer')
+* Procd based init system support ('start', 'stop', 'restart', 'reload', 'enable', 'disable', 'running', 'status', 'suspend', 'resume', 'query', 'report')
* Auto-Startup via procd network interface trigger or via classic time based startup
-* Suspend & Resume adblock temporarily without blocklist reloading
+* Suspend & Resume adblock temporarily without blocklist re-processing
* Provides comprehensive runtime information
* Provides a detailed DNS Query Report with DNS related information about client requests, top (blocked) domains and more
-* Provides a powerful query function to quickly find blocked (sub-)domains, e.g. for whitelisting
-* Provides an easily configurable blocklist update scheduler called 'Refresh Timer'
+* Provides a powerful query function to quickly find blocked (sub-)domains, e.g. to allow certain domains
* Includes an option to generate an additional, restrictive 'adb_list.jail' to block access to all domains except those listed in the whitelist file. You can use this restrictive blocklist manually e.g. for guest wifi or kidsafe configurations
* Includes an option to force DNS requests to the local resolver
* Automatic blocklist backup & restore, these backups will be used in case of download errors and during startup
-* Send notification E-Mails in case of a processing error or if the overall domain count is ≤ 0
-* Add new adblock sources on your own, see example below
+* Send notification E-Mails, see example configuration below
+* Add new adblock feeds on your own, see example below
* Strong LuCI support, all relevant options are exposed to the web frontend
+<a id="prerequisites"></a>
## Prerequisites
-* [OpenWrt](https://openwrt.org), tested with the stable release series and with the latest snapshot releases.
- <b>Please note:</b> Devices with less than 128 MByte RAM are _not_ supported!
- <b>Please note:</b> For performance reasons, adblock depends on gnu awk (gawk) by default.
- If you insist to use the slow busybox awk implementation, remove the gawk package afterwards (_opkg remove gawk --force-depends_) or install adblock without any dependency checks/installation (_opkg install adblock --nodeps_). Both installation variants are officially unsupported.
+* [OpenWrt](https://openwrt.org), tested with the stable release series and with the latest snapshot releases.
+ <b>Please note:</b> Devices with less than 128 MByte RAM are _not_ supported!
+ <b>Please note:</b> For performance reasons, adblock depends on gnu awk (gawk) by default.
+ If you insist to use the slow busybox awk implementation, remove the gawk package afterwards (_opkg remove gawk --force-depends_) or install adblock without any dependency checks/installation (_opkg install adblock --nodeps_). Both installation variants are officially unsupported.
* A usual setup with an enabled DNS backend at minimum - dumb AP modes without a working DNS backend are _not_ supported
-* A download utility with SSL support: 'wget', 'uclient-fetch' with one of the 'libustream-*' ssl libraries, 'aria2c' or 'curl' is required
+* A download utility with SSL support: 'wget', 'uclient-fetch' with one of the 'libustream-*' ssl libraries or 'curl' is required
* A certificate store such as 'ca-bundle' or 'ca-certificates', as adblock checks the validity of the SSL certificates of all download sites by default
* Optional E-Mail notification support: for E-Mail notifications you need to install the additional 'msmtp' package
* Optional DNS Query Report support: for DNS reporting you need to install the additional package 'tcpdump-mini' or 'tcpdump'
+<a id="installation-and-usage"></a>
## Installation & Usage
* Update your local opkg repository (_opkg update_)
* Install 'adblock' (_opkg install adblock_). The adblock service is enabled by default
* It's strongly recommended to use the LuCI frontend to easily configure all aspects of adblock, the application is located in LuCI under the 'Services' menu
* Update from a former adblock version is easy. During the update a backup is made of the old configuration '/etc/config/adblock-backup' and replaced by the new config - that's all
-## Adblock CLI Options
+<a id="adblock-cli-interface"></a>
+## Adblock CLI interface
* All important adblock functions are accessible via CLI as well.
-<pre><code>
-~# /etc/init.d/adblock
+
+```
+~# /etc/init.d/adblock
Syntax: /etc/init.d/adblock [command]
Available commands:
enabled Check if service is started on boot
suspend Suspend adblock processing
resume Resume adblock processing
- query <domain> Query active blocklists and backups for a specific domain
- report [<search>] Print DNS statistics with an optional search parameter
- list List available sources
- timer [<add> <tasks> <hour> [<minute>] [<weekday>]]|[<remove> <line no.>] List/Edit cron update intervals
- version Print version information
+ query <domain> Query active blocklists and backups for a specific domain
+ report [<cli>|<mail>|<gen>|<json>] Print DNS statistics
running Check if service is running
status Service status
trace Start with syscall trace
-</code></pre>
+ info Dump procd service info
+```
+<a id="adblock-config-options"></a>
## Adblock Config Options
* Usually the auto pre-configured adblock setup works quite well and no manual overrides are needed
| Option | Default | Description/Valid Values |
| :----------------- | :--------------------------------- | :--------------------------------------------------------------------------------------------- |
| adb_enabled | 1, enabled | set to 0 to disable the adblock service |
-| adb_srcarc | -, /etc/adblock/adblock.sources.gz | full path to the used adblock source archive |
-| adb_srcfile | -, /tmp/adb_sources.json | full path to the used adblock source file, which has a higher precedence than the archive file |
+| adb_feedfile | /etc/adblock/adblock.feeds | full path to the used adblock feed file |
| adb_dns | -, auto-detected | 'dnsmasq', 'unbound', 'named', 'kresd', 'smartdns' or 'raw' |
-| adb_fetchutil | -, auto-detected | 'uclient-fetch', 'wget', 'curl' or 'aria2c' |
+| adb_fetchutil | -, auto-detected | 'uclient-fetch', 'wget' or 'curl' |
| adb_fetchparm | -, auto-detected | manually override the config options for the selected download utility |
| adb_fetchinsecure | 0, disabled | don't check SSL server certificates during download |
| adb_trigger | -, not set | trigger network interface or 'not set' to use a time-based startup |
| adb_repchunkcnt | 5 | report chunk count used by tcpdump |
| adb_repchunksize | 1 | report chunk size used by tcpdump in MB |
| adb_represolve | 0, disabled | resolve reporting IP addresses using reverse DNS (PTR) lookups |
-| adb_backup | 1, enabled | set to 0 to disable the backup function |
| adb_tld | 1, enabled | set to 0 to disable the top level domain compression (tld) function |
| adb_backupdir | /tmp | path for adblock backups |
| adb_tmpbase | /tmp | path for all adblock related runtime operations, e.g. downloading, sorting, merging etc. |
-| adb_safesearch | 0, disabled | set to 1 to enforce SafeSearch for google, bing, duckduckgo, yandex, youtube and pixabay |
+| adb_safesearch | 0, disabled | enforce SafeSearch for google, bing, brave, duckduckgo, yandex, youtube and pixabay |
| adb_safesearchlist | -, not set | Limit SafeSearch to certain provider (see above) |
-| adb_safesearchmod | 0, disabled | set to 1 to enable moderate SafeSearch filters for youtube |
| adb_mail | 0, disabled | set to 1 to enable notification E-Mails in case of a processing errors |
| adb_mailreceiver | -, not set | receiver address for adblock notification E-Mails |
| adb_mailsender | no-reply@adblock | sender address for adblock notification E-Mails |
| adb_jail | 0 | set to 1 to enable the additional, restrictive 'adb_list.jail' creation |
| adb_jaildir | /tmp | path for the generated jail list |
+<a id="examples"></a>
## Examples
**Change the DNS backend to 'unbound':**
No further configuration is needed, adblock deposits the final blocklist 'adb_list.overall' in '/var/lib/unbound' by default.
Adblock deposits the final blocklist 'adb_list.overall' in '/var/lib/bind' by default.
To preserve the DNS cache after adblock processing please install the additional package 'bind-rdnc'.
To use the blocklist please modify '/etc/bind/named.conf':
-<pre><code>
+
+```
in the 'options' namespace add:
response-policy { zone "rpz"; };
allow-query { none; };
allow-transfer { none; };
};
-</code></pre>
+```
**Change the DNS backend to 'kresd':**
Adblock deposits the final blocklist 'adb_list.overall' in '/etc/kresd', no further configuration needed.
**Manually override the download options:**
By default adblock uses the following pre-configured download options:
-* aria2c: <code>--timeout=20 --allow-overwrite=true --auto-file-renaming=false --log-level=warn --dir=/ -o</code>
-* curl: <code>--connect-timeout 20 --silent --show-error --location -o</code>
-* uclient-fetch: <code>--timeout=20 -O</code>
-* wget: <code>--no-cache --no-cookies --max-redirect=0 --timeout=20 -O</code>
+* <code>curl: --connect-timeout 20 --silent --show-error --location -o</code>
+* <code>uclient-fetch: --timeout=20 -O</code>
+* <code>wget: --no-cache --no-cookies --max-redirect=0 --timeout=20 -O</code>
To override the default set 'adb_fetchparm' manually to your needs.
**Service status output:**
In LuCI you'll see the realtime status in the 'Runtime' section on the overview page.
To get the status in the CLI, just call _/etc/init.d/adblock status_ or _/etc/init.d/adblock status\_service_:
-<pre><code>
+
+```
~#@blackhole:~# /etc/init.d/adblock status
::: adblock runtime information
+ adblock_status : enabled
- + adblock_version : 4.2.3-r1
- + blocked_domains : 785573
- + active_sources : adguard, doh_blocklist, hagezi, winspy
- + dns_backend : dnsmasq (-), /tmp/dnsmasq.d
+ + adblock_version : 4.4.0-r1
+ + blocked_domains : 1 154 208
+ + active_feeds : 1hosts, certpl, cpbl, doh_blocklist, hagezi, winspy
+ + dns_backend : dnsmasq (-), /mnt/data/adblock/backup, 92.87 MB
+ run_utils : download: /usr/bin/curl, sort: /usr/libexec/sort-coreutils, awk: /usr/bin/gawk
+ run_ifaces : trigger: trm_wwan, report: br-lan
- + run_directories : base: /tmp, backup: /tmp/adblock-Backup, report: /tmp/adblock-Report, jail: /tmp
- + run_flags : backup: ✔, tld: ✔, force: ✔, flush: ✘, search: ✘, report: ✔, mail: ✘, jail: ✘
- + last_run : reload, 1m 3s, 650 MB available, 1664 KB max. used, 2024-11-23T18:11:41+01:00
- + system : OpenWrt One, mediatek/filogic, OpenWrt SNAPSHOT r28034-ca53f2d430
-</code></pre>
-The 'last\_run' line includes the used start type, the run duration, the memory footprint after DNS backend loading (total/free/available) and the date/time of the last run.
+ + run_directories : base: /mnt/data/adblock, backup: /mnt/data/adblock/backup, report: /mnt/data/adblock/report, jail: -
+ + run_flags : shift: ✔, force: ✔, flush: ✘, tld: ✔, search: ✘, report: ✔, mail: ✘, jail: ✘
+ + last_run : mode: reload, 2025-04-10T20:34:17+02:00, duration: 0m 55s, 682.52 MB available
+ + system_info : OpenWrt One, mediatek/filogic, OpenWrt 24.10-SNAPSHOT r28584-a51b1a98e0
+```
-**Edit, add new adblock sources:**
-The adblock blocklist sources are stored in an external, compressed JSON file '/etc/adblock/adblock.sources.gz'.
-This file is directly parsed in LuCI and accessible via CLI, just call _/etc/init.d/adblock list_:
-<pre><code>
-/etc/init.d/adblock list
-::: Available adblock sources
-:::
- Name Enabled Size Focus Info URL
- ------------------------------------------------------------------
- + adaway x S mobile https://adaway.org
- + adguard x L general https://adguard.com
- + andryou x L compilation https://gitlab.com/andryou/block/-/blob/master/readme.md
- + bitcoin x S mining https://github.com/hoshsadiq/adblock-nocoin-list
- + disconnect x S general https://disconnect.me
- + dshield XL general https://www.dshield.org
-[...]
- + winhelp S general http://winhelp2002.mvps.org
- + winspy x S win_telemetry https://github.com/crazy-max/WindowsSpyBlocker
- + yoyo x S general https://pgl.yoyo.org
-</code></pre>
+**Change/add adblock feeds**
+The adblock default blocklist feeds are stored in an external JSON file '/etc/adblock/adblock.feeds'. All custom changes should be stored in an external JSON file '/etc/adblock/adblock.custom.feeds' (empty by default). It's recommended to use the LuCI based Custom Feed Editor to make changes to this file.
+A valid JSON source object contains the following information, e.g.:
-To add new or edit existing sources extract the compressed JSON file _gunzip /etc/adblock/adblock.sources.gz_.
-A valid JSON source object contains the following required information, e.g.:
-<pre><code>
+```
[...]
- "adaway": {
- "url": "https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt",
- "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]+\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "mobile",
- "descurl": "https://github.com/AdAway/adaway.github.io"
+ "adguard": {
+ "url": "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "L",
+ "descr": "general"
},
[...]
-</code></pre>
-Add an unique object name, make the required changes to 'url', 'rule', 'size' and 'descurl' and finally compress the changed JSON file _gzip /etc/adblock/adblock.sources_ to use the new source object in adblock.
-<b>Please note:</b> if you're going to add new sources on your own, please make a copy of the default file and work with that copy further on, cause the default will be overwritten with every adblock update. To reference your copy set the option 'adb\_srcarc' which points by default to '/etc/adblock/adblock.sources.gz'
-<b>Please note:</b> when adblock starts, it looks for the uncompressed 'adb\_srcfile', only if this file is not found the archive 'adb\_srcarc' is unpacked once and then the uncompressed file is used
+```
+
+Add an unique feed name (no spaces, no special chars) and make the required changes: adapt at least the URL, the regex rule, the size and the description for a new feed.
## Support
Please join the adblock discussion in this [forum thread](https://forum.openwrt.org/t/adblock-support-thread/507) or contact me by mail <
[email protected]>
option adb_debug '0'
option adb_forcedns '0'
option adb_safesearch '0'
- option adb_dnsfilereset '0'
option adb_mail '0'
option adb_report '0'
- option adb_backup '1'
- list adb_sources 'adguard'
+ list adb_feed 'adguard'
--- /dev/null
+{
+ "1hosts": {
+ "url": "https://raw.githubusercontent.com/badmojr/1Hosts/master/",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "VAR",
+ "descr": "compilation"
+ },
+ "adaway": {
+ "url": "https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt",
+ "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "mobile"
+ },
+ "adguard": {
+ "url": "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "L",
+ "descr": "general"
+ },
+ "adguard_tracking": {
+ "url": "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_trackers_justdomains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "L",
+ "descr": "tracking"
+ },
+ "android_tracking": {
+ "url": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/android-tracking.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "tracking"
+ },
+ "andryou": {
+ "url": "https://gitlab.com/andryou/block/raw/master/kouhai-compressed-domains",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "L",
+ "descr": "compilation"
+ },
+ "anti_ad": {
+ "url": "https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "L",
+ "descr": "compilation"
+ },
+ "anudeep": {
+ "url": "https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "M",
+ "descr": "compilation"
+ },
+ "bitcoin": {
+ "url": "https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "mining"
+ },
+ "certpl": {
+ "url": "https://hole.cert.pl/domains/v2/domains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "L",
+ "descr": "phishing"
+ },
+ "cpbl": {
+ "url": "https://raw.githubusercontent.com/bongochong/CombinedPrivacyBlockLists/master/NoFormatting/cpbl-ctld.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XL",
+ "descr": "compilation"
+ },
+ "disconnect": {
+ "url": "https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "general"
+ },
+ "doh_blocklist": {
+ "url": "https://raw.githubusercontent.com/dibdot/DoH-IP-blocklists/master/doh-domains_overall.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "doh_server"
+ },
+ "easylist": {
+ "url": "https://easylist-downloads.adblockplus.org/easylist.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "M",
+ "descr": "compilation"
+ },
+ "easyprivacy": {
+ "url": "https://easylist-downloads.adblockplus.org/easyprivacy.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "M",
+ "descr": "tracking"
+ },
+ "energized_blu": {
+ "url": "https://energized.pro/blu/domains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XL",
+ "descr": "compilation"
+ },
+ "energized_spark": {
+ "url": "https://energized.pro/spark/domains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "L",
+ "descr": "compilation"
+ },
+ "energized_ultimate": {
+ "url": "https://energized.pro/ultimate/domains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XXL",
+ "descr": "compilation"
+ },
+ "firetv_tracking": {
+ "url": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/AmazonFireTV.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "tracking"
+ },
+ "games_tracking": {
+ "url": "https://raw.githubusercontent.com/KodoPengin/GameIndustry-hosts-Template/master/Main-Template/hosts",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "tracking"
+ },
+ "hblock": {
+ "url": "https://hblock.molinero.dev/hosts_domains.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XL",
+ "descr": "compilation"
+ },
+ "hagezi": {
+ "url": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "VAR",
+ "descr": "compilation"
+ },
+ "lightswitch05": {
+ "url": "https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "XL",
+ "descr": "compilation"
+ },
+ "notracking": {
+ "url": "https://raw.githubusercontent.com/notracking/hosts-blocklists/master/dnscrypt-proxy/dnscrypt-proxy.blacklist.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XL",
+ "descr": "tracking"
+ },
+ "oisd_big": {
+ "url": "https://big.oisd.nl/domainswild2",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XXL",
+ "descr": "general"
+ },
+ "oisd_nsfw": {
+ "url": "https://nsfw.oisd.nl/domainswild2",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "XXL",
+ "descr": "porn"
+ },
+ "oisd_nsfw_small": {
+ "url": "https://nsfw-small.oisd.nl/domainswild2",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "M",
+ "descr": "porn"
+ },
+ "oisd_small": {
+ "url": "https://small.oisd.nl/domainswild2",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "L",
+ "descr": "general"
+ },
+ "openphish": {
+ "url": "https://openphish.com/feed.txt",
+ "rule": "BEGIN{FS=\"\/\"}/^http[s]?:\\/\\/([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+(\\/|$)/{print tolower($3)}",
+ "size": "S",
+ "descr": "phishing"
+ },
+ "phishing_army": {
+ "url": "https://phishing.army/download/phishing_army_blocklist_extended.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "phishing"
+ },
+ "reg_cn": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistchina.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_china"
+ },
+ "reg_cz": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistczechslovak.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_czech+slovak"
+ },
+ "reg_de": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistgermany.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_germany"
+ },
+ "reg_es": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistspanish.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_spain"
+ },
+ "reg_fi": {
+ "url": "https://raw.githubusercontent.com/finnish-easylist-addition/finnish-easylist-addition/master/Finland_adb.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_finland"
+ },
+ "reg_fr": {
+ "url": "https://easylist-downloads.adblockplus.org/liste_fr.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "M",
+ "descr": "reg_france"
+ },
+ "reg_id": {
+ "url": "https://easylist-downloads.adblockplus.org/abpindo.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_indonesia"
+ },
+ "reg_it": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistitaly.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_italy"
+ },
+ "reg_jp": {
+ "url": "https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_japan"
+ },
+ "reg_kr": {
+ "url": "https://raw.githubusercontent.com/List-KR/List-KR/master/filters-share/adservice.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_korea"
+ },
+ "reg_lt": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistlithuania.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_lithuania"
+ },
+ "reg_nl": {
+ "url": "https://easylist-downloads.adblockplus.org/easylistdutch.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_netherlands"
+ },
+ "reg_pl": {
+ "url": "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "M",
+ "descr": "reg_poland"
+ },
+ "reg_ro": {
+ "url": "https://easylist-downloads.adblockplus.org/rolist.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_romania"
+ },
+ "reg_ru": {
+ "url": "https://easylist-downloads.adblockplus.org/ruadlist.txt",
+ "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
+ "size": "S",
+ "descr": "reg_russia"
+ },
+ "reg_se": {
+ "url": "https://raw.githubusercontent.com/lassekongo83/Frellwits-filter-lists/master/Frellwits-Swedish-Hosts-File.txt",
+ "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "reg_sweden"
+ },
+ "reg_vn": {
+ "url": "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "reg_vietnam"
+ },
+ "smarttv_tracking": {
+ "url": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "tracking"
+ },
+ "spam404": {
+ "url": "https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "general"
+ },
+ "stevenblack": {
+ "url": "https://raw.githubusercontent.com/StevenBlack/hosts/master/",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "VAR",
+ "descr": "compilation"
+ },
+ "stopforumspam": {
+ "url": "https://www.stopforumspam.com/downloads/toxic_domains_whole.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "spam"
+ },
+ "utcapitole": {
+ "url": "https://dsi.ut-capitole.fr/blacklists/download/blacklists.tar.gz",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "VAR",
+ "descr": "general"
+ },
+ "wally3k": {
+ "url": "https://v.firebog.net/hosts/static/w3kbl.txt",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "compilation"
+ },
+ "whocares": {
+ "url": "https://someonewhocares.org/hosts/hosts",
+ "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "M",
+ "descr": "general"
+ },
+ "winhelp": {
+ "url": "https://winhelp2002.mvps.org/hosts.txt",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "general"
+ },
+ "winspy": {
+ "url": "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt",
+ "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
+ "size": "S",
+ "descr": "win_telemetry"
+ },
+ "yoyo": {
+ "url": "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext",
+ "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
+ "size": "S",
+ "descr": "general"
+ }
+}
#!/bin/sh /etc/rc.common
# This is free software, licensed under the GNU General Public License v3.
# (s)hellcheck exceptions
extra_command "suspend" "Suspend adblock processing"
extra_command "resume" "Resume adblock processing"
extra_command "query" "<domain> Query active blocklists and backups for a specific domain"
-extra_command "report" "[[<cli>|<mail>|<gen>|<json>] [<top_count>] [<res_count>] [<search>]] Print DNS statistics with an optional search parameter"
-extra_command "list" "List available sources"
-extra_command "timer" "[<add> <tasks> <hour> [<minute>] [<weekday>]]|[<remove> <line no.>] List/Edit cron update intervals"
+extra_command "report" "[<cli>|<mail>|<gen>|<json>] Print DNS statistics"
adb_init="/etc/init.d/adblock"
adb_script="/usr/bin/adblock.sh"
adb_pidfile="/var/run/adblock.pid"
[ "${action}" = "boot" ] && "${adb_init}" running && exit 0
-[ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] || [ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ] || { [ "${action}" = "list" ] && [ -n "${1}" ]; }; } && exit 1
+[ -s "${adb_pidfile}" ] && { [ "${action}" = "start" ] || [ "${action}" = "stop" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "report" ] || [ "${action}" = "suspend" ] || [ "${action}" = "resume" ] || [ "${action}" = "query" ]; } && exit 1
boot() {
: >"${adb_pidfile}"
fi
}
+restart() {
+ rc_procd start_service restart
+}
+
reload_service() {
rc_procd start_service reload
}
rc_procd "${adb_script}" stop
}
-restart() {
- rc_procd "${adb_script}" stop
- rc_procd start_service restart
-}
-
suspend() {
rc_procd start_service suspend
}
rc_procd "${adb_script}" report "${1:-"cli"}" "${2}" "${3}" "${4}"
}
-list() {
- local src_archive src_file src_enabled enabled name utc_list size focus descurl
-
- src_archive="$(uci_get adblock global adb_srcarc "/etc/adblock/adblock.sources.gz")"
- src_file="$(uci_get adblock global adb_srcfile "/tmp/adb_sources.json")"
- src_enabled="$(uci -q show adblock.global.adb_sources)"
- [ -r "${src_archive}" ] && zcat "${src_archive}" >"${src_file}" || printf "%s\n" "::: adblock source archive '${src_archive}' not found"
-
- if [ -r "${src_file}" ]; then
- src_enabled="${src_enabled#*=}"
- src_enabled="${src_enabled//\'}"
- printf "%s\n" "::: Available adblock sources"
- printf "%s\n" ":::"
- printf "%-25s%-10s%-7s%-21s%s\n" " Name" "Enabled" "Size" "Focus" "Info URL"
- printf "%s\n" " -------------------------------------------------------------------"
- json_load_file "${src_file}"
- json_get_keys keylist
- for key in ${keylist}; do
- json_select "${key}"
- json_get_var size "size"
- json_get_var focus "focus"
- json_get_var descurl "descurl"
- json_get_var url "url"
- json_get_var rule "rule"
- if [ -n "${url}" ] && [ -n "${rule}" ]; then
- if printf "%s" "${src_enabled}" | grep -q "${key}"; then
- enabled="x"
- else
- enabled=" "
- fi
- src_enabled="${src_enabled/${key}}"
- printf " + %-21s%-10s%-7s%-21s%s\n" "${key:0:20}" "${enabled}" "${size:0:3}" "${focus:0:20}" "${descurl:0:50}"
- else
- src_enabled="${src_enabled} ${key}"
- fi
- json_select ..
- done
- utc_list="$(uci_get adblock global adb_utc_sources "-")"
- hag_list="$(uci_get adblock global adb_hag_sources "-")"
- stb_list="$(uci_get adblock global adb_stb_sources "-")"
- printf "%s\n" " ---------------------------------------------------------------------------"
- printf " * %s\n" "Configured utcapitole categories: ${utc_list// /, }"
- printf " * %s\n" "Configured hagezi variants: ${hag_list// /, }"
- printf " * %s\n" "Configured stevenblack variants: ${stb_list// /, }"
-
- if [ -n "${src_enabled// }" ]; then
- printf "%s\n" " ---------------------------------------------------------------------------"
- printf "%s\n" " Sources with invalid configuration"
- printf "%s\n" " ---------------------------------------------------------------------------"
- for key in ${src_enabled}; do
- printf " - %s\n" "${key:0:20}"
- done
- fi
- else
- printf "%s\n" "::: adblock source file '${src_file}' not found"
- fi
-}
-
status() {
status_service
}
status_service() {
- local key keylist value values rtfile
+ local key keylist value values
- rtfile="$(uci_get adblock global adb_rtfile "/tmp/adb_runtime.json")"
json_init
- json_load_file "${rtfile}" >/dev/null 2>&1
+ json_load_file "/var/run/adb_runtime.json" >/dev/null 2>&1
json_get_keys keylist
if [ -n "${keylist}" ]; then
printf "%s\n" "::: adblock runtime information"
for key in ${keylist}; do
json_get_var value "${key}" >/dev/null 2>&1
- if [ "${key}" = "active_sources" ]; then
+ if [ "${key}" = "active_feeds" ]; then
json_get_values values "${key}" >/dev/null 2>&1
value="${values// /, }"
fi
fi
}
-timer() {
- local cron_file cron_content cron_lineno action="${1:-"list"}" cron_tasks="${2}" hour="${3}" minute="${4:-0}" weekday="${5:-"*"}"
-
- cron_file="/etc/crontabs/root"
-
- if [ -s "${cron_file}" ] && [ "${action}" = "list" ]; then
- awk '{print NR "> " $0}' "${cron_file}"
- elif [ -x "/etc/init.d/cron" ] && [ "${action}" = "add" ]; then
- hour="${hour//[[:alpha:]]/}"
- minute="${minute//[[:alpha:]]/}"
- if [ -n "${cron_tasks}" ] && [ -n "${hour}" ] && [ -n "${minute}" ] && [ -n "${weekday}" ] &&
- [ "${hour}" -ge 0 ] && [ "${hour}" -le 23 ] &&
- [ "${minute}" -ge 0 ] && [ "${minute}" -le 59 ]; then
- printf "%02d %02d %s\n" "${minute}" "${hour}" "* * ${weekday} ${adb_init} ${cron_tasks}" >>"${cron_file}"
- /etc/init.d/cron restart
- fi
- elif [ -x "/etc/init.d/cron" ] && [ -s "${cron_file}" ] && [ "${action}" = "remove" ]; then
- cron_tasks="${cron_tasks//[[:alpha:]]/}"
- cron_lineno="$(awk 'END{print NR}' "${cron_file}")"
- cron_content="$(awk '{print $0}' "${cron_file}")"
- if [ "${cron_tasks:-"0"}" -le "${cron_lineno:-"1"}" ] && [ -n "${cron_content}" ]; then
- printf "%s\n" "${cron_content}" | awk "NR!~/^${cron_tasks}$/" >"${cron_file}"
- /etc/init.d/cron restart
- fi
- fi
-}
-
service_triggers() {
local iface delay
PROCD_RELOAD_DELAY="$((delay * 1000))"
[ -n "${iface}" ] && procd_add_interface_trigger "interface.*.up" "${iface}" "${adb_init}" start
-
- PROCD_RELOAD_DELAY="$((2 * 1000))"
- procd_add_reload_trigger "adblock"
}
adb_enabled="0"
adb_debug="0"
-adb_forcedns="0"
+adb_dnsforce="0"
+adb_dnsshift="0"
adb_dnsflush="0"
adb_dnstimeout="20"
adb_safesearch="0"
-adb_safesearchmod="0"
adb_report="0"
adb_trigger=""
adb_triggerdelay="5"
-adb_backup="1"
adb_mail="0"
adb_jail="0"
adb_tld="1"
adb_dns=""
adb_dnspid=""
-adb_dnsprefix="adb_list"
-adb_locallist="blacklist whitelist iplist"
+adb_locallist="allowlist blocklist iplist"
adb_tmpbase="/tmp"
-adb_backupdir="${adb_tmpbase}/adblock-Backup"
-adb_reportdir="${adb_tmpbase}/adblock-Report"
+adb_finaldir=""
+adb_backupdir="/tmp/adblock-backup"
+adb_reportdir="/tmp/adblock-report"
adb_jaildir=""
adb_pidfile="/var/run/adblock.pid"
-adb_blacklist="/etc/adblock/adblock.blacklist"
-adb_whitelist="/etc/adblock/adblock.whitelist"
+adb_allowlist="/etc/adblock/adblock.allowlist"
+adb_blocklist="/etc/adblock/adblock.blocklist"
adb_mailservice="/etc/adblock/adblock.mail"
-adb_dnsfile="${adb_dnsprefix}.overall"
-adb_dnsjail="${adb_dnsprefix}.jail"
-adb_srcarc="/etc/adblock/adblock.sources.gz"
-adb_srcfile="${adb_tmpbase}/adb_sources.json"
-adb_rtfile="${adb_tmpbase}/adb_runtime.json"
-adb_fetchutil=""
+adb_dnsfile="adb_list.overall"
+adb_dnsjail="adb_list.jail"
+adb_feedfile="/etc/adblock/adblock.feeds"
+adb_rtfile="/var/run/adb_runtime.json"
+adb_fetchcmd=""
adb_fetchinsecure=""
+adb_fetchparm=""
+adb_etagparm=""
adb_repiface=""
adb_replisten="53"
adb_repchunkcnt="5"
adb_repchunksize="1"
adb_represolve="0"
-adb_lookupdomain="example.com"
+adb_lookupdomain="localhost"
adb_action="${1:-"start"}"
adb_packages=""
adb_cnt=""
f_jsnup "running"
f_extconf
f_temp
-
- if [ ! -r "${adb_srcfile}" ]; then
- if [ -r "${adb_srcarc}" ]; then
- "${adb_zcatcmd}" "${adb_srcarc}" >"${adb_srcfile}"
- else
- f_log "err" "adblock source archive not found"
- fi
- fi
- if [ -r "${adb_srcfile}" ] && [ "${adb_action}" != "report" ]; then
- json_init
- json_load_file "${adb_srcfile}"
+ json_init
+ if [ -s "${adb_feedfile}" ] && json_load_file "${adb_feedfile}" >/dev/null 2>&1; then
+ return
else
- f_log "err" "adblock source file not found"
+ f_log "err" "can't load adblock feed file"
fi
}
;;
esac
+ if [ "${adb_dnsshift}" = "0" ]; then
+ adb_finaldir="${adb_dnsdir}"
+ else
+ adb_finaldir="${adb_backupdir}"
+ fi
if [ "${adb_action}" != "stop" ]; then
- [ ! -d "${adb_dnsdir}" ] && mkdir -p "${adb_dnsdir:-"/tmp"}"
+ [ ! -d "${adb_backupdir}" ] && mkdir -p "${adb_backupdir}"
+ [ ! -d "${adb_finaldir}" ] && mkdir -p "${adb_finaldir:-"/tmp"}"
[ "${adb_jail}" = "1" ] && [ ! -d "${adb_jaildir}" ] && mkdir -p "${adb_jaildir:-"/tmp"}"
- [ "${adb_backup}" = "1" ] && [ ! -d "${adb_backupdir}" ] && mkdir -p "${adb_backupdir}"
if [ "${adb_dnsflush}" = "1" ] || [ "${mem_free}" -lt "64" ]; then
- printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
f_dnsup
- elif [ ! -f "${adb_dnsdir}/${adb_dnsfile}" ]; then
- printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
+ elif [ ! -f "${adb_finaldir}/${adb_dnsfile}" ]; then
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
fi
fi
- f_log "debug" "f_dns ::: dns: ${adb_dns}, dns_dir: ${adb_dnsdir}, dns_file: ${adb_dnsfile}, dns_user: ${adb_dnsuser}, dns_instance: ${adb_dnsinstance}, backup_dir: ${adb_backupdir}, jail_dir: ${adb_jaildir}"
+ f_log "debug" "f_dns ::: dns: ${adb_dns}, dns_instance: ${adb_dnsinstance}, dns_user: ${adb_dnsuser}, dns_dir: ${adb_dnsdir}, backup_dir: ${adb_backupdir}, final_dir: ${adb_finaldir}, jail_dir: ${adb_jaildir}"
}
# load fetch utility
#
f_fetch() {
- local util utils insecure
+ local util utils insecure update="0"
- adb_fetchutil="$(command -v "${adb_fetchutil}")"
- if [ ! -x "${adb_fetchutil}" ]; then
- utils="aria2 curl wget-ssl libustream-openssl libustream-wolfssl libustream-mbedtls"
+ adb_fetchcmd="$(command -v "${adb_fetchcmd}")"
+ if [ ! -x "${adb_fetchcmd}" ]; then
+ utils="curl wget-ssl libustream-openssl libustream-wolfssl libustream-mbedtls"
for util in ${utils}; do
if printf "%s" "${adb_packages}" | "${adb_jsoncmd}" -ql1 -e "@.packages[\"${util}\"]" >/dev/null 2>&1; then
case "${util}" in
- "aria2")
- util="aria2c"
- ;;
"wget-ssl")
util="wget"
;;
esac
if [ -x "$(command -v "${util}")" ]; then
- adb_fetchutil="$(command -v "${util}")"
- uci_set adblock global adb_fetchutil "${util}"
+ update="1"
+ adb_fetchcmd="$(command -v "${util}")"
+ uci_set adblock global adb_fetchcmd "${util}"
f_uci "adblock"
break
fi
done
fi
- [ ! -x "${adb_fetchutil}" ] && f_log "err" "download utility with SSL support not found, please set 'adb_fetchutil' manually"
+ [ ! -x "${adb_fetchcmd}" ] && f_log "err" "download utility with SSL support not found, please set 'adb_fetchcmd' manually"
- case "${adb_fetchutil##*/}" in
- "aria2c")
- [ "${adb_fetchinsecure}" = "1" ] && insecure="--check-certificate=false"
- adb_fetchparm="${adb_fetchparm:-"${insecure} --timeout=20 --allow-overwrite=true --auto-file-renaming=false --log-level=warn --dir=/ -o"}"
- ;;
+ case "${adb_fetchcmd##*/}" in
"curl")
[ "${adb_fetchinsecure}" = "1" ] && insecure="--insecure"
adb_fetchparm="${adb_fetchparm:-"${insecure} --connect-timeout 20 --fail --silent --show-error --location -o"}"
- ;;
- "uclient-fetch")
- [ "${adb_fetchinsecure}" = "1" ] && insecure="--no-check-certificate"
- adb_fetchparm="${adb_fetchparm:-"${insecure} --timeout=20 -O"}"
+ adb_etagparm="--connect-timeout 5 --silent --location --head"
;;
"wget")
[ "${adb_fetchinsecure}" = "1" ] && insecure="--no-check-certificate"
adb_fetchparm="${adb_fetchparm:-"${insecure} --no-cache --no-cookies --max-redirect=0 --timeout=20 -O"}"
+ adb_etagparm="--timeout=5 --spider --server-response"
+ ;;
+ "uclient-fetch")
+ [ "${adb_fetchinsecure}" = "1" ] && insecure="--no-check-certificate"
+ adb_fetchparm="${adb_fetchparm:-"${insecure} --timeout=20 -O"}"
;;
esac
- f_log "debug" "f_fetch ::: fetch_util: ${adb_fetchutil:-"-"}, fetch_parm: ${adb_fetchparm:-"-"}"
+ f_log "debug" "f_fetch ::: update: ${update}, cmd: ${adb_fetchcmd:-"-"}"
}
# create temporary files, directories and set dependent options
# remove temporary files and directories
#
f_rmtemp() {
- rm -rf "${adb_tmpdir}" "${adb_srcfile}"
+ rm -rf "${adb_tmpdir}"
: >"${adb_pidfile}"
- if [ "${adb_backup}" = "0" ]; then
- rm -f "${adb_backupdir}/${adb_dnsprefix}".*.gz
- fi
- if [ "${adb_action}" != "suspend" ]; then
- rm -f "${adb_backupdir}/${adb_dnsfile}.gz"
- fi
}
# remove dns related files
#
f_rmdns() {
- if "${adb_ubuscmd}" -S call service list 2>/dev/null | "${adb_jsoncmd}" -ql1 -e '@["adblock"].instances.*.running' >/dev/null; then
- : >"${adb_rtfile}"
- printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
- f_dnsup 4
- fi
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
+ f_dnsup
f_rmtemp
}
"/etc/init.d/firewall" reload >/dev/null 2>&1
;;
"resolver")
- printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
adb_cnt="0"
f_jsnup "running"
"/etc/init.d/${adb_dns}" reload >/dev/null 2>&1
printf "%s" "${adb_cnt}"
else
if [ "${mode}" = "final" ]; then
- if [ -s "${adb_tmpdir}/tmp.add.whitelist" ]; then
- adb_cnt="$((adb_cnt - $("${adb_wccmd}" -l 2>/dev/null <"${adb_tmpdir}/tmp.add.whitelist")))"
+ if [ -s "${adb_tmpdir}/tmp.add.allowlist" ]; then
+ adb_cnt="$((adb_cnt - $("${adb_wccmd}" -l 2>/dev/null <"${adb_tmpdir}/tmp.add.allowlist")))"
fi
for file in "${adb_tmpdir}/tmp.safesearch".*; do
if [ -r "${file}" ]; then
case "${adb_dns}" in
"kresd")
config="resolver"
- config_option="$(uci_get ${config} kresd rpz_file | "${adb_grepcmd}" -Fo "${adb_dnsdir}/${adb_dnsfile}")"
- if [ "${adb_enabled}" = "1" ] && [ -z "${config_option}" ]; then
- uci -q add_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}"
+ if [ "${adb_enabled}" = "1" ] && ! uci_get ${config} kresd rpz_file >/dev/null 2>&1; then
+ uci -q add_list ${config}.kresd.rpz_file="${adb_finaldir}/${adb_dnsfile}"
elif [ "${adb_enabled}" = "0" ] && [ -n "${config_option}" ]; then
- uci -q del_list resolver.kresd.rpz_file="${adb_dnsdir}/${adb_dnsfile}"
+ uci -q del_list ${config}.kresd.rpz_file="${adb_finaldir}/${adb_dnsfile}"
fi
;;
"smartdns")
config="smartdns"
- config_option="$(uci_get ${config} smartdns conf_files | "${adb_grepcmd}" -Fo "${adb_dnsdir}/${adb_dnsfile}")"
- if [ "${adb_enabled}" = "1" ] && [ -z "${config_option}" ]; then
- uci -q add_list smartdns.@smartdns[${adb_dnsinstance}].conf_files="${adb_dnsdir}/${adb_dnsfile}"
+ if [ "${adb_enabled}" = "1" ] && ! uci_get ${config} @${config}[${adb_dnsinstance}] conf_files >/dev/null 2>&1; then
+ uci -q add_list ${config}.@${config}[${adb_dnsinstance}].conf_files="${adb_finaldir}/${adb_dnsfile}"
elif [ "${adb_enabled}" = "0" ] && [ -n "${config_option}" ]; then
- uci -q del_list smartdns.@smartdns[${adb_dnsinstance}].conf_files="${adb_dnsdir}/${adb_dnsfile}"
+ uci -q del_list ${config}.@${config}[${adb_dnsinstance}].conf_files="${adb_finaldir}/${adb_dnsfile}"
fi
;;
esac
f_uci "${config}"
fwcfg="$(uci -qNX show "firewall" | "${adb_awkcmd}" 'BEGIN{FS="[.=]"};/adblock_/{if(zone==$2){next}else{ORS=" ";zone=$2;print zone}}')"
- if [ "${adb_enabled}" = "1" ] && [ "${adb_forcedns}" = "1" ] &&
+ if [ "${adb_enabled}" = "1" ] && [ "${adb_dnsforce}" = "1" ] &&
/etc/init.d/firewall enabled; then
for zone in ${adb_zonelist}; do
for port in ${adb_portlist}; do
fwcfg="${fwcfg#"${fwcfg%%[![:space:]]*}"}"
fwcfg="${fwcfg%"${fwcfg##*[![:space:]]}"}"
fi
- if [ "${adb_enabled}" = "0" ] || [ "${adb_forcedns}" = "0" ] || [ -n "${fwcfg}" ]; then
+ if [ "${adb_enabled}" = "0" ] || [ "${adb_dnsforce}" = "0" ] || [ -n "${fwcfg}" ]; then
config="firewall"
for section in ${fwcfg}; do
uci_remove firewall "${section}"
# restart dns backend
#
f_dnsup() {
- local rset dns_service dns_up restart_rc cnt="0" out_rc="4" in_rc="${1:-0}"
+ local restart_rc cnt="0" out_rc="4"
adb_dnspid=""
if [ "${adb_dns}" = "raw" ] || [ -z "${adb_dns}" ]; then
out_rc="0"
else
- if [ "${in_rc}" = "0" ] && [ "${adb_dnsflush}" = "0" ]; then
+ if [ "${adb_dnsflush}" = "0" ]; then
case "${adb_dns}" in
"unbound")
if [ -x "${adb_dnscachecmd}" ] && [ -d "${adb_tmpdir}" ] && [ -f "${adb_dnsdir}/unbound.conf" ]; then
restart_rc="${?}"
fi
;;
+ "dnsmasq")
+ if [ "${adb_dnsshift}" = "1" ] &&
+ ! uci_get dhcp @dnsmasq[${adb_dnsinstance}] addnmount >/dev/null 2>&1; then
+ uci -q add_list dhcp.@dnsmasq[${adb_dnsinstance}].addnmount="${adb_backupdir}"
+ fi
+ "/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
+ restart_rc="${?}"
+ uci -q revert dhcp
+ ;;
*)
"/etc/init.d/${adb_dns}" restart >/dev/null 2>&1
restart_rc="${?}"
restart_rc="${?}"
fi
fi
- if [ "${restart_rc}" = "0" ] && [ "${in_rc}" = "0" ]; then
+ if [ "${restart_rc}" = "0" ]; then
while [ "${cnt}" -le "${adb_dnstimeout}" ]; do
- if [ -n "${adb_lookupdomain}" ] && [ "${adb_lookupdomain}" != "false" ]; then
- if "${adb_lookupcmd}" "${adb_lookupdomain}" >/dev/null 2>&1; then
- out_rc="0"
- break
- fi
- else
- sleep "${adb_dnstimeout}"
- cnt="${adb_dnstimeout}"
+ if "${adb_lookupcmd}" "${adb_lookupdomain}." >/dev/null 2>&1; then
out_rc="0"
+ break
fi
cnt="$((cnt + 1))"
sleep 1
fi
adb_dnspid="$("${adb_ubuscmd}" -S call service list 2>/dev/null | "${adb_jsoncmd}" -l1 -e "@[\"${adb_dns}\"].instances.*.pid")"
- f_log "debug" "f_dnsup ::: dns: ${adb_dns}, cache_cmd: ${adb_dnscachecmd:-"-"}, lookup_domain: ${adb_lookupdomain:-"-"}, restart_rc: ${restart_rc:-"-"}, dns_flush: ${adb_dnsflush}, dns_timeout: ${adb_dnstimeout}, dns_pid: ${adb_dnspid}, dns_cnt: ${cnt}, in_rc: ${in_rc}, out_rc: ${out_rc}"
+ f_log "debug" "f_dnsup ::: dns: ${adb_dns}, cache_cmd: ${adb_dnscachecmd:-"-"}, lookup_domain: ${adb_lookupdomain:-"-"}, restart_rc: ${restart_rc:-"-"}, dns_flush: ${adb_dnsflush}, dns_timeout: ${adb_dnstimeout}, dns_pid: ${adb_dnspid}, dns_cnt: ${cnt}, rc: ${out_rc}"
+ return "${out_rc}"
+}
+
+# handle etag http header
+#
+f_etag() {
+ local http_head http_code etag_id etag_cnt out_rc="4" feed="${1}" feed_url="${2}" feed_suffix="${3}" feed_cnt="${4:-"1"}"
+
+ [ ! -f "${adb_backupdir}/adblock.etag" ] && : >"${adb_backupdir}/adblock.etag"
+ http_head="$("${adb_fetchcmd}" ${adb_etagparm} "${feed_url}${feed_suffix}" 2>&1)"
+ http_code="$(printf "%s" "${http_head}" | "${adb_awkcmd}" 'tolower($0)~/^http\/[0123\.]+ /{printf "%s",$2}')"
+ etag_id="$(printf "%s" "${http_head}" | "${adb_awkcmd}" 'tolower($0)~/^[[:space:]]*etag: /{gsub("\"","");printf "%s",$2}')"
+ if [ -z "${etag_id}" ]; then
+ etag_id="$(printf "%s" "${http_head}" | "${adb_awkcmd}" 'tolower($0)~/^[[:space:]]*last-modified: /{gsub(/[Ll]ast-[Mm]odified:|[[:space:]]|,|:/,"");printf "%s\n",$1}')"
+ fi
+ etag_cnt="$("${adb_grepcmd}" -c "^${feed}" "${adb_backupdir}/adblock.etag")"
+ if [ "${http_code}" = "200" ] && [ "${etag_cnt}" = "${feed_cnt}" ] && [ -n "${etag_id}" ] &&
+ "${adb_grepcmd}" -q "^${feed}${feed_suffix}[[:space:]]\+${etag_id}\$" "${adb_backupdir}/adblock.etag"; then
+ out_rc="0"
+ elif [ -n "${etag_id}" ]; then
+ if [ "${feed_cnt}" -lt "${etag_cnt}" ]; then
+ "${adb_sedcmd}" -i "/^${feed}/d" "${adb_backupdir}/adblock.etag"
+ else
+ "${adb_sedcmd}" -i "/^${feed}${feed_suffix}/d" "${adb_backupdir}/adblock.etag"
+ fi
+ printf "%-50s%s\n" "${feed}${feed_suffix}" "${etag_id}" >>"${adb_backupdir}/adblock.etag"
+ out_rc="2"
+ fi
+
+ f_log "debug" "f_etag ::: feed: ${feed}, suffix: ${feed_suffix:-"-"}, http_code: ${http_code:-"-"}, feed/etag: ${feed_cnt}/${etag_cnt:-"0"}, rc: ${out_rc}"
return "${out_rc}"
}
# backup/restore/remove blocklists
#
f_list() {
- local file rset item array safe_url safe_ips safe_cname safe_domains ip out_rc file_name mode="${1}" src_name="${2:-"${src_name}"}" in_rc="${src_rc:-0}" use_cname="0" ffiles="-maxdepth 1 -name ${adb_dnsprefix}.*.gz"
+ local file rset item array safe_url safe_ips safe_cname safe_domains ip out_rc file_name mode="${1}" src_name="${2:-"${src_name}"}" in_rc="${src_rc:-0}" use_cname="0" ffiles="-maxdepth 1 -name adb_list.*.gz"
case "${mode}" in
"iplist")
: >"${adb_tmpdir}/tmp.raw.${src_name}"
fi
;;
- "blacklist" | "whitelist")
+ "blocklist" | "allowlist")
src_name="${mode}"
- rset="/^(([[:alnum:]_-]{1,63}\\.)+[[:alnum:]-]+|[[:alnum:]-]+)([[:space:]]|$)/{print tolower(\$1)}"
+ rset="/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower(\$1)}"
case "${src_name}" in
- "blacklist")
- if [ -f "${adb_blacklist}" ]; then
+ "blocklist")
+ if [ -f "${adb_blocklist}" ]; then
file_name="${adb_tmpfile}.${src_name}"
- "${adb_awkcmd}" "${rset}" "${adb_blacklist}" >"${adb_tmpdir}/tmp.raw.${src_name}"
- if [ -s "${adb_whitelist}" ]; then
- "${adb_awkcmd}" 'NR==FNR{member[$1];next}!($1 in member)' "${adb_whitelist}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}"
+ "${adb_awkcmd}" "${rset}" "${adb_blocklist}" >"${adb_tmpdir}/tmp.raw.${src_name}"
+ if [ -s "${adb_allowlist}" ]; then
+ "${adb_awkcmd}" 'NR==FNR{member[$1];next}!($1 in member)' "${adb_allowlist}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}"
else
"${adb_catcmd}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.deduplicate.${src_name}"
fi
fi
fi
;;
- "whitelist")
- if [ -f "${adb_whitelist}" ]; then
+ "allowlist")
+ if [ -f "${adb_allowlist}" ]; then
file_name="${adb_tmpdir}/tmp.raw.${src_name}"
- [ "${adb_lookupdomain}" != "false" ] && printf "%s\n" "${adb_lookupdomain}" | "${adb_awkcmd}" "${rset}" >"${file_name}"
- "${adb_awkcmd}" "${rset}" "${adb_whitelist}" >>"${file_name}"
+ printf "%s\n" "${adb_lookupdomain}" | "${adb_awkcmd}" "${rset}" >"${file_name}"
+ "${adb_awkcmd}" "${rset}" "${adb_allowlist}" >>"${file_name}"
"${adb_awkcmd}" "${rset}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.rem.${src_name}"
out_rc="${?}"
- if [ "${adb_dnsallow}" != "1" ]; then
- eval "${adb_dnsallow}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.add.${src_name}"
- if [ "${adb_jail}" = "1" ] && [ "${adb_dnsstop}" != "0" ]; then
- rm -f "${adb_jaildir}/${adb_dnsjail}"
- [ -n "${adb_dnsheader}" ] && printf "%b" "${adb_dnsheader}" >>"${adb_jaildir}/${adb_dnsjail}"
- "${adb_catcmd}" "${adb_tmpdir}/tmp.add.${src_name}" >>"${adb_jaildir}/${adb_dnsjail}"
- printf "%b\n" "${adb_dnsstop}" >>"${adb_jaildir}/${adb_dnsjail}"
- fi
+ eval "${adb_dnsallow}" "${adb_tmpdir}/tmp.raw.${src_name}" >"${adb_tmpdir}/tmp.add.${src_name}"
+ if [ "${adb_jail}" = "1" ] && [ "${adb_dnsstop}" != "0" ]; then
+ rm -f "${adb_jaildir}/${adb_dnsjail}"
+ [ -n "${adb_dnsheader}" ] && printf "%b" "${adb_dnsheader}" >>"${adb_jaildir}/${adb_dnsjail}"
+ "${adb_catcmd}" "${adb_tmpdir}/tmp.add.${src_name}" >>"${adb_jaildir}/${adb_dnsjail}"
+ printf "%b\n" "${adb_dnsstop}" >>"${adb_jaildir}/${adb_dnsjail}"
fi
fi
;;
rset="/^\\.([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{printf \"%s\n%s\n\",tolower(\"www\"\$1),tolower(substr(\$1,2,length(\$1)))}"
safe_url="https://www.google.com/supported_domains"
safe_cname="forcesafesearch.google.com"
- if [ "${adb_backup}" = "1" ] && [ -s "${adb_backupdir}/safesearch.${src_name}.gz" ]; then
+ if [ -s "${adb_backupdir}/safesearch.${src_name}.gz" ]; then
"${adb_zcatcmd}" "${adb_backupdir}/safesearch.${src_name}.gz" >"${adb_tmpdir}/tmp.load.safesearch.${src_name}"
else
- "${adb_fetchutil}" ${adb_fetchparm} "${adb_tmpdir}/tmp.load.safesearch.${src_name}" "${safe_url}" 2>/dev/null
- if [ "${adb_backup}" = "1" ] && [ -s "${adb_tmpdir}/tmp.load.safesearch.${src_name}" ]; then
+ "${adb_fetchcmd}" ${adb_fetchparm} "${adb_tmpdir}/tmp.load.safesearch.${src_name}" "${safe_url}" 2>/dev/null
+ if [ -s "${adb_tmpdir}/tmp.load.safesearch.${src_name}" ]; then
"${adb_gzipcmd}" -cf "${adb_tmpdir}/tmp.load.safesearch.${src_name}" >"${adb_backupdir}/safesearch.${src_name}.gz"
fi
fi
safe_cname="strict.bing.com"
safe_domains="www.bing.com"
;;
+ "brave")
+ safe_cname="forcesafe.search.brave.com"
+ safe_domains="search.brave.com"
+ ;;
"duckduckgo")
safe_cname="safe.duckduckgo.com"
safe_domains="duckduckgo.com"
safe_domains="ya.ru yandex.ru yandex.com yandex.com.tr yandex.ua yandex.by yandex.ee yandex.lt yandex.lv yandex.md yandex.uz yandex.tm yandex.tj yandex.az yandex.kz"
;;
"youtube")
- if [ "${adb_safesearchmod}" = "0" ]; then
- safe_cname="restrict.youtube.com"
- else
- safe_cname="restrictmoderate.youtube.com"
- fi
+ safe_cname="restrict.youtube.com"
safe_domains="www.youtube.com m.youtube.com youtubei.googleapis.com youtube.googleapis.com www.youtube-nocookie.com"
;;
esac
: >"${adb_tmpdir}/tmp.raw.safesearch.${src_name}"
fi
;;
- "download")
+ "prepare")
file_name="${src_tmpfile}"
+ if [ -s "${src_tmpload}" ]; then
+ "${adb_awkcmd}" "${src_rset}" "${src_tmpload}" | "${adb_sedcmd}" "s/\r//g" |
+ { [ "${adb_tld}" = "1" ] && "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' || "${adb_catcmd}"; } |
+ "${adb_sortcmd}" ${adb_srtopts} -u >"${src_tmpfile}" 2>/dev/null
+ out_rc="${?}"
+ if [ "${out_rc}" = "0" ] && [ -s "${src_tmpfile}" ]; then
+ f_list backup
+ elif [ "${adb_action}" != "start" ]; then
+ f_log "info" "preparation of '${src_name}' failed, rc: ${src_rc}"
+ f_list restore
+ out_rc="${?}"
+ : >"${src_tmpfile}"
+ fi
+ else
+ f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}"
+ if [ "${adb_action}" != "start" ]; then
+ f_list restore
+ out_rc="${?}"
+ fi
+ fi
;;
"backup")
file_name="${src_tmpfile}"
- "${adb_gzipcmd}" -cf "${src_tmpfile}" >"${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz"
+ "${adb_gzipcmd}" -cf "${src_tmpfile}" >"${adb_backupdir}/adb_list.${src_name}.gz"
out_rc="${?}"
;;
"restore")
file_name="${src_tmpfile}"
- if [ -n "${src_name}" ] && [ -s "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" ]; then
- "${adb_zcatcmd}" "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" >"${src_tmpfile}"
+ if [ -n "${src_name}" ] && [ -s "${adb_backupdir}/adb_list.${src_name}.gz" ]; then
+ "${adb_zcatcmd}" "${adb_backupdir}/adb_list.${src_name}.gz" >"${src_tmpfile}"
out_rc="${?}"
elif [ -z "${src_name}" ]; then
- for file in "${adb_backupdir}/${adb_dnsprefix}".*.gz; do
+ for file in "${adb_backupdir}/adb_list."*.gz; do
if [ -r "${file}" ]; then
name="${file##*/}"
name="${name%.*}"
out_rc=4
fi
if [ "${adb_action}" != "start" ] && [ "${adb_action}" != "restart" ] && [ "${adb_action}" != "resume" ] && [ -n "${src_name}" ] && [ "${out_rc}" != "0" ]; then
- adb_sources="${adb_sources/${src_name}}"
+ adb_feed="${adb_feed/${src_name}}"
fi
;;
"remove")
- [ "${adb_backup}" = "1" ] && rm "${adb_backupdir}/${adb_dnsprefix}.${src_name}.gz" 2>/dev/null
+ rm "${adb_backupdir}/adb_list.${src_name}.gz" 2>/dev/null
out_rc="${?}"
- adb_sources="${adb_sources/${src_name}}"
+ adb_feed="${adb_feed/${src_name}}"
;;
"merge")
src_name=""
file_name="${adb_tmpdir}/${adb_dnsfile}"
- if [ "${adb_backup}" = "1" ]; then
- for file in ${adb_sources}; do
- ffiles="${ffiles} -a ! -name ${adb_dnsprefix}.${file}.gz"
- done
- if [ "${adb_safesearch}" = "1" ] && [ "${adb_dnssafesearch}" != "0" ]; then
- ffiles="${ffiles} -a ! -name safesearch.google.gz"
- fi
- find "${adb_backupdir}" ${ffiles} -print0 2>/dev/null | xargs -0 rm 2>/dev/null
+ for file in ${adb_feed}; do
+ ffiles="${ffiles} -a ! -name adb_list.${file}.gz"
+ done
+ if [ "${adb_safesearch}" = "1" ] && [ "${adb_dnssafesearch}" != "0" ]; then
+ ffiles="${ffiles} -a ! -name safesearch.google.gz"
fi
+ find "${adb_backupdir}" ${ffiles} -print0 2>/dev/null | xargs -0 rm 2>/dev/null
"${adb_sortcmd}" ${adb_srtopts} -mu "${adb_tmpfile}".* 2>/dev/null >"${file_name}"
out_rc="${?}"
rm -f "${adb_tmpfile}".*
;;
"final")
src_name=""
- file_name="${adb_dnsdir}/${adb_dnsfile}"
- : >"${file_name}"
+ file_name="${adb_finaldir}/${adb_dnsfile}"
+ rm -f "${file_name}"
[ -n "${adb_dnsheader}" ] && printf "%b" "${adb_dnsheader}" >>"${file_name}"
[ -s "${adb_tmpdir}/tmp.add.iplist" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.add.iplist" >>"${file_name}"
- [ -s "${adb_tmpdir}/tmp.add.whitelist" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.add.whitelist" >>"${file_name}"
+ [ -s "${adb_tmpdir}/tmp.add.allowlist" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.add.allowlist" >>"${file_name}"
[ "${adb_safesearch}" = "1" ] && "${adb_catcmd}" "${adb_tmpdir}/tmp.safesearch."* 2>/dev/null >>"${file_name}"
if [ "${adb_dnsdeny}" != "0" ]; then
eval "${adb_dnsdeny}" "${adb_tmpdir}/${adb_dnsfile}" >>"${file_name}"
else
"${adb_catcmd}" "${adb_tmpdir}/${adb_dnsfile}" >>"${file_name}"
fi
+ if [ "${adb_dnsshift}" = "1" ] && [ ! -L "${adb_dnsdir}/${adb_dnsfile}" ]; then
+ ln -fs "${file_name}" "${adb_dnsdir}/${adb_dnsfile}"
+ elif [ "${adb_dnsshift}" = "0" ] && [ -s "${adb_backupdir}/${adb_dnsfile}" ]; then
+ rm -f "${adb_backupdir}/${adb_dnsfile}"
+ fi
out_rc="0"
;;
esac
- [ "${adb_debug}" = "1" ] || [ "${mode}" = "final" ] && f_count "${mode}" "${file_name}"
+ f_count "${mode}" "${file_name}"
out_rc="${out_rc:-"${in_rc}"}"
f_log "debug" "f_list ::: name: ${src_name:-"-"}, mode: ${mode}, cnt: ${adb_cnt}, in_rc: ${in_rc}, out_rc: ${out_rc}"
if "${adb_awkcmd}" '{if(NR==1){tld=$NF};while(getline){if(index($NF,tld".")==0){print tld;tld=$NF}}print tld}' "${source}" |
"${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' >"${temp_tld}"; then
[ "${adb_debug}" = "1" ] && cnt_tld="$(f_count tld "${temp_tld}" "var")"
- if [ -s "${adb_tmpdir}/tmp.rem.whitelist" ]; then
- "${adb_awkcmd}" 'NR==FNR{del[$0];next};!($0 in del)' "${adb_tmpdir}/tmp.rem.whitelist" "${temp_tld}" >"${source}"
+ if [ -s "${adb_tmpdir}/tmp.rem.allowlist" ]; then
+ "${adb_awkcmd}" 'NR==FNR{del[$0];next};!($0 in del)' "${adb_tmpdir}/tmp.rem.allowlist" "${temp_tld}" >"${source}"
[ "${adb_debug}" = "1" ] && cnt_rem="$(f_count tld "${source}" "var")"
else
"${adb_catcmd}" "${temp_tld}" >"${source}"
json_get_var status "adblock_status"
f_env
if [ "${mode}" = "suspend" ] && [ "${status}" = "enabled" ]; then
- if [ -f "${adb_dnsdir}/${adb_dnsfile}" ]; then
- "${adb_gzipcmd}" -cf "${adb_dnsdir}/${adb_dnsfile}" >"${adb_backupdir}/${adb_dnsfile}.gz"
+ if [ "${adb_dnsshift}" = "0" ] && [ -f "${adb_finaldir}/${adb_dnsfile}" ]; then
+ mv -f "${adb_finaldir}/${adb_dnsfile}" "${adb_backupdir}/${adb_dnsfile}"
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
+ done="true"
+ elif [ "${adb_dnsshift}" = "1" ] && [ -L "${adb_dnsdir}/${adb_dnsfile}" ]; then
+ rm -f "${adb_dnsdir}/${adb_dnsfile}"
printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
done="true"
fi
elif [ "${mode}" = "resume" ] && [ "${status}" = "paused" ]; then
- if [ -f "${adb_backupdir}/${adb_dnsfile}.gz" ]; then
- "${adb_gzipcmd}" -dcf "${adb_backupdir}/${adb_dnsfile}.gz" >"${adb_dnsdir}/${adb_dnsfile}"
- f_count "resume" "${adb_dnsdir}/${adb_dnsfile}"
+ if [ "${adb_dnsshift}" = "0" ] && [ -f "${adb_backupdir}/${adb_dnsfile}" ]; then
+ mv -f "${adb_backupdir}/${adb_dnsfile}" "${adb_finaldir}/${adb_dnsfile}"
+ f_count "resume" "${adb_finaldir}/${adb_dnsfile}"
+ done="true"
+ elif [ "${adb_dnsshift}" = "1" ] && [ ! -L "${adb_finaldir}/${adb_dnsfile}" ]; then
+ ln -fs "${adb_finaldir}/${adb_dnsfile}" "${adb_dnsdir}/${adb_dnsfile}"
+ f_count "resume" "${adb_finaldir}/${adb_dnsfile}"
done="true"
fi
fi
f_dnsup
f_jsnup "${mode}"
f_log "info" "${mode} adblock service"
+ f_rmtemp
+ else
+ f_jsnup "stopped"
+ f_rmdns
fi
- f_rmtemp
}
# query blocklist for certain (sub-)domains
while :; do
search="${domain//[+*~%\$&\"\']/}"
search="${search//./\\.}"
- result="$("${adb_awkcmd}" -F '/|\"|\t| ' "/^(${prefix}${search}${suffix})$/{i++;if(i<=9){printf \" + %s\n\",\$${field}}else if(i==10){printf \" + %s\n\",\"[...]\";exit}}" "${adb_dnsdir}/${adb_dnsfile}")"
+ result="$("${adb_awkcmd}" -F '/|\"|\t| ' "/^(${prefix}${search}${suffix})$/{i++;if(i<=9){printf \" + %s\n\",\$${field}}else if(i==10){printf \" + %s\n\",\"[...]\";exit}}" "${adb_finaldir}/${adb_dnsfile}")"
printf "%s\n%s\n%s\n" ":::" "::: domain '${domain}' in active blocklist" ":::"
printf "%s\n\n" "${result:-" - no match"}"
[ "${domain}" = "${tld}" ] && break
domain="${tld}"
tld="${domain#*.}"
done
- if [ "${adb_backup}" = "1" ] && [ -d "${adb_backupdir}" ]; then
+ if [ -d "${adb_backupdir}" ]; then
search="${1//[+*~%\$&\"\']/}"
search="${search//./\\.}"
- printf "%s\n%s\n%s\n" ":::" "::: domain '${1}' in backups and black-/whitelist" ":::"
- for file in "${adb_backupdir}/${adb_dnsprefix}".*.gz "${adb_blacklist}" "${adb_whitelist}"; do
+ printf "%s\n%s\n%s\n" ":::" "::: domain '${1}' in backups and in local block-/allowlist" ":::"
+ for file in "${adb_backupdir}/adb_list".*.gz "${adb_blocklist}" "${adb_allowlist}"; do
suffix="${file##*.}"
if [ "${suffix}" = "gz" ]; then
- if [ "${adb_tld}" = "1" ]; then
- "${adb_zcatcmd}" "${file}" 2>/dev/null |
- "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' |
- "${adb_awkcmd}" -v f="${file##*/}" "BEGIN{rc=1};/^($search|.*\\.${search})$/{i++;if(i<=3){printf \" + %-30s%s\n\",f,\$1;rc=0}else if(i==4){printf \" + %-30s%s\n\",f,\"[...]\"}};END{exit rc}"
- else
- "${adb_zcatcmd}" "${file}" 2>/dev/null |
- "${adb_awkcmd}" -v f="${file##*/}" "BEGIN{rc=1};/^($search|.*\\.${search})$/{i++;if(i<=3){printf \" + %-30s%s\n\",f,\$1;rc=0}else if(i==4){printf \" + %-30s%s\n\",f,\"[...]\"}};END{exit rc}"
- fi
+ "${adb_zcatcmd}" "${file}" 2>/dev/null |
+ { [ "${adb_tld}" = "1" ] && "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' || :"${adb_catcmd}"; } |
+ "${adb_awkcmd}" -v f="${file##*/}" "BEGIN{rc=1};/^($search|.*\\.${search})$/{i++;if(i<=3){printf \" + %-30s%s\n\",f,\$1;rc=0}else if(i==4){printf \" + %-30s%s\n\",f,\"[...]\"}};END{exit rc}"
+ rc="${?}"
else
"${adb_awkcmd}" -v f="${file##*/}" "BEGIN{rc=1};/^($search|.*\\.${search})$/{i++;if(i<=3){printf \" + %-30s%s\n\",f,\$1;rc=0}else if(i==4){printf \" + %-30s%s\n\",f,\"[...]\"}};END{exit rc}" "${file}"
+ rc="${?}"
fi
- if [ "${?}" = "0" ]; then
+ if [ "${rc}" = "0" ]; then
result="true"
query_end="$(date "+%s")"
if [ "$((query_end - query_start))" -gt "${query_timeout}" ]; then
# update runtime information
#
f_jsnup() {
- local pids object sources runtime utils mem_dns mem_free mem_max status="${1:-"enabled"}"
+ local pids object feeds end_time runtime utils mem_dns mem_free status="${1:-"enabled"}"
if [ -n "${adb_dnspid}" ]; then
pids="$("${adb_pgrepcmd}" -P "${adb_dnspid}" 2>/dev/null)"
mem_dns="$("${adb_awkcmd}" -v mem="${mem_dns}" 'BEGIN{printf "%.2f", mem/1024}' 2>/dev/null)"
fi
mem_free="$("${adb_awkcmd}" '/^MemAvailable/{printf "%.2f", $2/1024}' "/proc/meminfo" 2>/dev/null)"
- mem_max="$("${adb_awkcmd}" '/^VmHWM/{printf "%.2f", $2/1024}' "/proc/${$}/status" 2>/dev/null)"
adb_cnt="$("${adb_awkcmd}" -v cnt="${adb_cnt}" 'BEGIN{res="";pos=0;for(i=length(cnt);i>0;i--){res=substr(cnt,i,1)res;pos++;if(pos==3&&i>1){res=" "res;pos=0;}}; printf"%s",res}')"
case "${status}" in
"enabled")
- adb_endtime="$(date "+%s")"
- if [ "$(((adb_endtime - adb_starttime) / 60))" -lt 60 ]; then
- runtime="${adb_action}, $(((adb_endtime - adb_starttime) / 60))m $(((adb_endtime - adb_starttime) % 60))s, ${mem_free:-0} MB available, ${mem_max:-0} MB max. used, $(date -Iseconds)"
- else
- runtime="${adb_action}, n/a, ${mem_free:-0} MB available, ${mem_max:-0} MB max. used, $(date -Iseconds)"
+ if [ -n "${adb_starttime}" ] && [ "${adb_action}" != "boot" ]; then
+ end_time="$(date "+%s")"
+ duration="$(((end_time - adb_starttime) / 60))m $(((end_time - adb_starttime) % 60))s"
fi
+ runtime="mode: ${adb_action}, $(date -Iseconds), duration: ${duration:-"-"}, ${mem_free:-0} MB available"
;;
- "error")
+ "error"|"stopped")
adb_cnt="0"
;;
"resume")
json_init
if json_load_file "${adb_rtfile}" >/dev/null 2>&1; then
- utils="download: $(readlink -fn "${adb_fetchutil}"), sort: $(readlink -fn "${adb_sortcmd}"), awk: $(readlink -fn "${adb_awkcmd}")"
+ utils="download: $(readlink -fn "${adb_fetchcmd}"), sort: $(readlink -fn "${adb_sortcmd}"), awk: $(readlink -fn "${adb_awkcmd}")"
[ -z "${adb_cnt}" ] && json_get_var adb_cnt "blocked_domains"
[ -z "${runtime}" ] && json_get_var runtime "last_run"
+ if [ "${status}" = "enabled" ]; then
+ if [ "${adb_jail}" = "1" ] && [ "${adb_jaildir}" = "${adb_dnsdir}" ]; then
+ adb_cnt="0"
+ feeds="restrictive_jail"
+ else
+ feeds="$(printf "%s\n" ${adb_feed} | "${adb_sortcmd}" | "${adb_awkcmd}" '{ORS=" ";print $0}')"
+ fi
+ fi
fi
-
- if [ "${adb_jail}" = "1" ] && [ "${adb_jaildir}" = "${adb_dnsdir}" ]; then
- adb_cnt="0"
- sources="restrictive_jail"
- else
- sources="$(printf "%s\n" ${adb_sources} | "${adb_sortcmd}" | "${adb_awkcmd}" '{ORS=" ";print $0}')"
- fi
-
- : >"${adb_rtfile}"
+ printf "%s\n" "{}" >"${adb_rtfile}"
json_init
json_load_file "${adb_rtfile}" >/dev/null 2>&1
json_add_string "adblock_status" "${status}"
json_add_string "adblock_version" "${adb_ver}"
json_add_string "blocked_domains" "${adb_cnt:-"0"}"
- json_add_array "active_sources"
- for object in ${sources:-"-"}; do
+ json_add_array "active_feeds"
+ for object in ${feeds:-"-"}; do
json_add_string "${object}" "${object}"
done
json_close_array
- json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_dnsdir:-"-"}, ${mem_dns:-"0"} MB"
+ json_add_string "dns_backend" "${adb_dns:-"-"} (${adb_dnscachecmd##*/}), ${adb_finaldir:-"-"}, ${mem_dns:-"0"} MB"
json_add_string "run_utils" "${utils:-"-"}"
json_add_string "run_ifaces" "trigger: ${adb_trigger:-"-"}, report: ${adb_repiface:-"-"}"
- json_add_string "run_directories" "base: ${adb_tmpbase}, backup: ${adb_backupdir}, report: ${adb_reportdir}, jail: ${adb_jaildir}"
- json_add_string "run_flags" "backup: $(f_char ${adb_backup}), tld: $(f_char ${adb_tld}), force: $(f_char ${adb_forcedns}), flush: $(f_char ${adb_dnsflush}), search: $(f_char ${adb_safesearch}), report: $(f_char ${adb_report}), mail: $(f_char ${adb_mail}), jail: $(f_char ${adb_jail})"
+ json_add_string "run_directories" "base: ${adb_tmpbase}, backup: ${adb_backupdir}, report: ${adb_reportdir}, jail: ${adb_jaildir:-"-"}"
+ json_add_string "run_flags" "shift: $(f_char ${adb_dnsshift}), force: $(f_char ${adb_dnsforce}), flush: $(f_char ${adb_dnsflush}), tld: $(f_char ${adb_tld}), search: $(f_char ${adb_safesearch}), report: $(f_char ${adb_report}), mail: $(f_char ${adb_mail}), jail: $(f_char ${adb_jail})"
json_add_string "last_run" "${runtime:-"-"}"
- json_add_string "system" "${adb_sysver}"
+ json_add_string "system_info" "${adb_sysver}"
json_dump >"${adb_rtfile}"
if [ "${adb_mail}" = "1" ] && [ -x "${adb_mailservice}" ] && [ "${status}" = "enabled" ]; then
# main function for blocklist processing
#
f_main() {
- local src_tmpload src_tmpfile src_name src_rset src_url src_arc src_cat src_item src_list src_entries src_suffix src_rc entry cnt
+ local src_tmpload src_tmpfile src_name src_rset src_url src_cat src_item src_list src_entries src_suffix src_rc entry cnt
- # white- and blacklist preparation
+ # allow- and blocklist preparation
#
cnt="1"
for entry in ${adb_locallist}; do
[ "${cnt}" -gt "${adb_cores}" ] && wait -n
cnt="$((cnt + 1))"
done
+ wait
if [ "${adb_dns}" != "raw" ] && [ "${adb_jail}" = "1" ] && [ "${adb_jaildir}" = "${adb_dnsdir}" ]; then
- printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
chown "${adb_dnsuser}" "${adb_jaildir}/${adb_dnsjail}" 2>/dev/null
if f_dnsup; then
if [ "${adb_action}" != "resume" ]; then
fi
f_rmtemp
return
- elif [ -f "${adb_dnsdir}/${adb_dnsjail}" ]; then
- rm -f "${adb_dnsdir}/${adb_dnsjail}"
+ elif [ -f "${adb_finaldir}/${adb_dnsjail}" ]; then
+ rm -f "${adb_finaldir}/${adb_dnsjail}"
f_dnsup
fi
# safe search preparation
#
if [ "${adb_safesearch}" = "1" ] && [ "${adb_dnssafesearch}" != "0" ]; then
- [ -z "${adb_safesearchlist}" ] && adb_safesearchlist="google bing duckduckgo pixabay yandex youtube"
+ [ -z "${adb_safesearchlist}" ] && adb_safesearchlist="google bing brave duckduckgo pixabay yandex youtube"
cnt="1"
for entry in ${adb_safesearchlist}; do
(
[ "${cnt}" -gt "${adb_cores}" ] && wait -n
cnt="$((cnt + 1))"
done
+ wait
fi
# main loop
#
cnt="1"
- for src_name in ${adb_sources}; do
+ for src_name in ${adb_feed}; do
if ! json_select "${src_name}" >/dev/null 2>&1; then
- adb_sources="${adb_sources/${src_name}/}"
+ adb_feed="${adb_feed/${src_name}/}"
continue
fi
json_get_var src_url "url" >/dev/null 2>&1
json_select ..
src_tmpcat="${adb_tmpload}.${src_name}.cat"
src_tmpload="${adb_tmpload}.${src_name}.load"
+ src_tmparchive="${adb_tmpload}.${src_name}.archive"
src_tmpfile="${adb_tmpfile}.${src_name}"
+
src_rc=4
# basic pre-checks
continue
fi
- # backup/restore mode
- #
- if [ "${adb_backup}" = "1" ] && { [ "${adb_action}" = "start" ] || [ "${adb_action}" = "restart" ] || [ "${adb_action}" = "resume" ]; }; then
- if f_list restore && [ -s "${src_tmpfile}" ]; then
- continue
- fi
- fi
-
# download queue processing
#
- unset src_cat src_entries
- if [ "${src_name}" = "utcapitole" ] && [ -n "${adb_utc_sources}" ]; then
- src_cat="${adb_utc_sources}"
- if [ -n "${src_cat}" ]; then
- (
- src_arc="${adb_tmpdir}/${src_url##*/}"
- "${adb_fetchutil}" ${adb_fetchparm} "${src_arc}" "${src_url}" >/dev/null 2>&1
- src_rc="${?}"
- if [ "${src_rc}" = "0" ] && [ -s "${src_arc}" ]; then
- src_suffix="$(eval printf "%s" \"\$\{adb_src_suffix_${src_name}:-\"domains\"\}\")"
- src_list="$(tar -tzf "${src_arc}" 2>/dev/null)"
- for src_item in ${src_cat}; do
- src_entries="${src_entries} $(printf "%s" "${src_list}" | "${adb_grepcmd}" -E "${src_item}/${src_suffix}$")"
- done
- if [ -n "${src_entries}" ]; then
- tar -xOzf "${src_arc}" ${src_entries} 2>/dev/null >"${src_tmpload}"
- src_rc="${?}"
- fi
- : >"${src_arc}"
- else
- f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}"
+ src_cat=""
+ src_entries=""
+ [ "${src_name}" = "1hosts" ] && src_cat="${adb_hst_feed}"
+ [ "${src_name}" = "hagezi" ] && src_cat="${adb_hag_feed}"
+ [ "${src_name}" = "stevenblack" ] && src_cat="${adb_stb_feed}"
+ if [ -n "${src_cat}" ]; then
+ (
+ # restore handling on boot, resume or (re-)start
+ #
+ if [ "${adb_action}" = "boot" ] || [ "${adb_action}" = "start" ] || [ "${adb_action}" = "restart" ] || [ "${adb_action}" = "resume" ]; then
+ if f_list restore && [ -s "${src_tmpfile}" ]; then
+ continue
fi
- if [ "${src_rc}" = "0" ] && [ -s "${src_tmpload}" ]; then
- if [ "${adb_tld}" = "1" ]; then
- "${adb_awkcmd}" "${src_rset}" "${src_tmpload}" | "${adb_sedcmd}" "s/\r//g" |
- "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' |
- "${adb_sortcmd}" ${adb_srtopts} -u 2>/dev/null >"${src_tmpfile}"
- src_rc="${?}"
- else
- "${adb_awkcmd}" "${src_rset}" "${src_tmpload}" | "${adb_sedcmd}" "s/\r//g" |
- "${adb_sortcmd}" ${adb_srtopts} -u 2>/dev/null >"${src_tmpfile}"
- src_rc="${?}"
- fi
- if [ "${src_rc}" = "0" ] && [ -s "${src_tmpfile}" ]; then
- f_list download
- [ "${adb_backup}" = "1" ] && f_list backup
- elif [ "${adb_backup}" = "1" ] && [ "${adb_action}" != "start" ]; then
- f_log "info" "archive preparation of '${src_name}' failed, categories: ${src_cat:-"-"}, entries: ${src_entries}, rc: ${src_rc}"
- f_list restore
- : >"${src_tmpfile}"
+ fi
+ # etag handling on reload
+ #
+ etag_rc="0"
+ src_cnt="$(printf "%s" "${src_cat}" | "${adb_wccmd}" -w)"
+ for suffix in ${src_cat}; do
+ if [ -n "${adb_etagparm}" ] && [ "${adb_action}" = "reload" ]; then
+ if ! f_etag "${src_name}" "${src_url}" "${suffix}" "${src_cnt}"; then
+ etag_rc="$(( etag_rc + 1))"
fi
- elif [ "${adb_backup}" = "1" ] && [ "${adb_action}" != "start" ]; then
- f_log "info" "archive extraction of '${src_name}' failed, categories: ${src_cat:-"-"}, entries: ${src_entries}, rc: ${src_rc}"
- f_list restore
fi
- ) &
- fi
+ done
+ if [ "${etag_rc}" = "0" ];then
+ if f_list restore; then
+ continue
+ fi
+ fi
+ # normal download
+ #
+ for suffix in ${src_cat}; do
+ "${adb_fetchcmd}" ${adb_fetchparm} "${src_tmpcat}" "${src_url}${suffix}" >/dev/null 2>&1
+ src_rc="${?}"
+ if [ "${src_rc}" = "0" ] && [ -s "${src_tmpcat}" ]; then
+ "${adb_catcmd}" "${src_tmpcat}" >>"${src_tmpload}"
+ : >"${src_tmpcat}"
+ fi
+ done
+ # list preparation
+ #
+ f_list prepare
+ ) &
else
- case "${src_name}" in
- "1hosts")
- [ -n "${adb_hst_sources}" ] && src_cat="${adb_hst_sources}" || continue
- ;;
- "hagezi")
- [ -n "${adb_hag_sources}" ] && src_cat="${adb_hag_sources}" || continue
- ;;
- "stevenblack")
- [ -n "${adb_stb_sources}" ] && src_cat="${adb_stb_sources}" || continue
- ;;
- esac
(
- for suffix in ${src_cat:-${src_url}}; do
- if [ "${src_url}" != "${suffix}" ]; then
- "${adb_fetchutil}" ${adb_fetchparm} "${src_tmpcat}" "${src_url}${suffix}" >/dev/null 2>&1
- src_rc="${?}"
- if [ "${src_rc}" = "0" ] && [ -s "${src_tmpcat}" ]; then
- "${adb_catcmd}" "${src_tmpcat}" >>"${src_tmpload}"
- : >"${src_tmpcat}"
+ [ "${src_name}" = "utcapitole" ] && src_cat="${adb_utc_feed}"
+ # restore handling on boot, resume or (re-)start
+ #
+ if [ "${adb_action}" = "boot" ] || [ "${adb_action}" = "start" ] || [ "${adb_action}" = "restart" ] || [ "${adb_action}" = "resume" ]; then
+ if f_list restore && [ -s "${src_tmpfile}" ]; then
+ continue
+ fi
+ fi
+ # etag handling on reload
+ #
+ if [ -n "${adb_etagparm}" ] && [ "${adb_action}" = "reload" ]; then
+ if f_etag "${src_name}" "${src_url}"; then
+ if f_list restore && [ -s "${src_tmpfile}" ]; then
+ continue
fi
- else
- "${adb_fetchutil}" ${adb_fetchparm} "${src_tmpload}" "${src_url}" >/dev/null 2>&1
- src_rc="${?}"
fi
- done
- if [ "${src_rc}" = "0" ] && [ -s "${src_tmpload}" ]; then
- if [ "${adb_tld}" = "1" ]; then
- "${adb_awkcmd}" "${src_rset}" "${src_tmpload}" | "${adb_sedcmd}" "s/\r//g" |
- "${adb_awkcmd}" 'BEGIN{FS="."}{for(f=NF;f>1;f--)printf "%s.",$f;print $1}' |
- "${adb_sortcmd}" ${adb_srtopts} -u >"${src_tmpfile}"
- src_rc="${?}"
- else
- "${adb_awkcmd}" "${src_rset}" "${src_tmpload}" | "${adb_sedcmd}" "s/\r//g" |
- "${adb_sortcmd}" ${adb_srtopts} -u >"${src_tmpfile}"
+ fi
+ # normal download
+ #
+ if [ "${src_name}" = "utcapitole" ]; then
+ if [ -n "${src_cat}" ]; then
+ "${adb_fetchcmd}" ${adb_fetchparm} "${src_tmparchive}" "${src_url}" >/dev/null 2>&1
src_rc="${?}"
- fi
- if [ "${src_rc}" = "0" ] && [ -s "${src_tmpfile}" ]; then
- f_list download
- [ "${adb_backup}" = "1" ] && f_list backup
- elif [ "${adb_backup}" = "1" ] && [ "${adb_action}" != "start" ]; then
- f_log "info" "preparation of '${src_name}' failed, rc: ${src_rc}"
- f_list restore
- : >"${src_tmpfile}"
+ if [ "${src_rc}" = "0" ] && [ -s "${src_tmparchive}" ]; then
+ src_suffix="$(eval printf "%s" \"\$\{adb_src_suffix_${src_name}:-\"domains\"\}\")"
+ src_list="$(tar -tzf "${src_tmparchive}" 2>/dev/null)"
+ for src_item in ${src_cat}; do
+ src_entries="${src_entries} $(printf "%s" "${src_list}" | "${adb_grepcmd}" -E "${src_item}/${src_suffix}$")"
+ done
+ if [ -n "${src_entries}" ]; then
+ tar -xOzf "${src_tmparchive}" ${src_entries} 2>/dev/null >"${src_tmpload}"
+ src_rc="${?}"
+ fi
+ : >"${src_tmparchive}"
+ fi
fi
else
- f_log "info" "download of '${src_name}' failed, url: ${src_url}, rule: ${src_rset:-"-"}, categories: ${src_cat:-"-"}, rc: ${src_rc}"
- [ "${adb_backup}" = "1" ] && [ "${adb_action}" != "start" ] && f_list restore
+ "${adb_fetchcmd}" ${adb_fetchparm} "${src_tmpload}" "${src_url}" >/dev/null 2>&1
+ src_rc="${?}"
fi
+ # list preparation
+ #
+ f_list prepare
) &
fi
[ "${cnt}" -gt "${adb_cores}" ] && wait -n
[ "${adb_tld}" = "1" ] && f_tld "${adb_tmpdir}/${adb_dnsfile}"
f_list final
else
- printf "%b" "${adb_dnsheader}" >"${adb_dnsdir}/${adb_dnsfile}"
+ printf "%b" "${adb_dnsheader}" >"${adb_finaldir}/${adb_dnsfile}"
fi
- chown "${adb_dnsuser}" "${adb_dnsdir}/${adb_dnsfile}" 2>/dev/null
+ chown "${adb_dnsuser}" "${adb_finaldir}/${adb_dnsfile}" 2>/dev/null
if f_dnsup; then
[ "${adb_action}" != "resume" ] && f_jsnup "enabled"
f_log "info" "blocklist with overall ${adb_cnt} blocked domains loaded successfully (${adb_sysver})"
# build json file
#
if [ "${action}" != "json" ]; then
- : >"${report_raw}"
- : >"${report_srt}"
- : >"${report_txt}"
- : >"${report_jsn}"
+ : >"${report_raw}" >"${report_srt}" >"${report_txt}" >"${report_jsn}"
[ "${adb_represolve}" = "1" ] && resolve=""
for file in "${adb_reportdir}/adb_report.pcap"*; do
(
f_load
case "${adb_action}" in
"stop")
+ f_jsnup "stopped"
f_rmdns
;;
"suspend")
"query")
f_query "${2}"
;;
- "start" | "reload" | "restart")
+ "start" | "reload")
+ f_env
+ f_main
+ ;;
+ "restart")
+ f_jsnup "running"
+ f_rmdns
f_env
f_main
;;
+++ /dev/null
-{
- "1hosts": {
- "url": "https://raw.githubusercontent.com/badmojr/1Hosts/master/",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "VAR",
- "focus": "compilation",
- "descurl": "https://github.com/badmojr/1Hosts"
- },
- "adaway": {
- "url": "https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt",
- "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "mobile",
- "descurl": "https://github.com/AdAway/adaway.github.io"
- },
- "adguard": {
- "url": "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt",
- "rule": "BEGIN{FS=\"[\/|^|\\r]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+[\\/\\^\\r]+$/{print tolower($3)}",
- "size": "L",
- "focus": "general",
- "descurl": "https://adguard.com"
- },
- "adguard_tracking": {
- "url": "https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_trackers_justdomains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "L",
- "focus": "tracking",
- "descurl": "https://github.com/AdguardTeam/cname-trackers"
- },
- "android_tracking": {
- "url": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/android-tracking.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "tracking",
- "descurl": "https://github.com/Perflyst/PiHoleBlocklist"
- },
- "andryou": {
- "url": "https://gitlab.com/andryou/block/raw/master/kouhai-compressed-domains",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "L",
- "focus": "compilation",
- "descurl": "https://gitlab.com/andryou/block/-/blob/master/readme.md"
- },
- "anti_ad": {
- "url": "https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "L",
- "focus": "compilation",
- "descurl": "https://github.com/privacy-protection-tools/anti-AD/blob/master/README.md"
- },
- "anudeep": {
- "url": "https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "M",
- "focus": "compilation",
- "descurl": "https://github.com/anudeepND/blacklist"
- },
- "bitcoin": {
- "url": "https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "mining",
- "descurl": "https://github.com/hoshsadiq/adblock-nocoin-list"
- },
- "certpl": {
- "url": "https://hole.cert.pl/domains/v2/domains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "L",
- "focus": "phishing",
- "descurl": "https://cert.pl"
- },
- "cpbl": {
- "url": "https://raw.githubusercontent.com/bongochong/CombinedPrivacyBlockLists/master/NoFormatting/cpbl-ctld.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XL",
- "focus": "compilation",
- "descurl": "https://github.com/bongochong/CombinedPrivacyBlockLists"
- },
- "disconnect": {
- "url": "https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "general",
- "descurl": "https://disconnect.me"
- },
- "doh_blocklist": {
- "url": "https://raw.githubusercontent.com/dibdot/DoH-IP-blocklists/master/doh-domains_overall.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "doh_server",
- "descurl": "https://github.com/dibdot/DoH-IP-blocklists"
- },
- "easylist": {
- "url": "https://easylist-downloads.adblockplus.org/easylist.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "M",
- "focus": "compilation",
- "descurl": "https://easylist.to"
- },
- "easyprivacy": {
- "url": "https://easylist-downloads.adblockplus.org/easyprivacy.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "M",
- "focus": "tracking",
- "descurl": "https://easylist.to"
- },
- "energized_blu": {
- "url": "https://energized.pro/blu/domains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XL",
- "focus": "compilation",
- "descurl": "https://energized.pro"
- },
- "energized_spark": {
- "url": "https://energized.pro/spark/domains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "L",
- "focus": "compilation",
- "descurl": "https://energized.pro"
- },
- "energized_ultimate": {
- "url": "https://energized.pro/ultimate/domains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XXL",
- "focus": "compilation",
- "descurl": "https://energized.pro"
- },
- "firetv_tracking": {
- "url": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/AmazonFireTV.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "tracking",
- "descurl": "https://github.com/Perflyst/PiHoleBlocklist"
- },
- "games_tracking": {
- "url": "https://raw.githubusercontent.com/KodoPengin/GameIndustry-hosts-Template/master/Main-Template/hosts",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "tracking",
- "descurl": "https://www.gameindustry.eu"
- },
- "hblock": {
- "url": "https://hblock.molinero.dev/hosts_domains.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XL",
- "focus": "compilation",
- "descurl": "https://hblock.molinero.dev"
- },
- "hagezi": {
- "url": "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "VAR",
- "focus": "compilation",
- "descurl": "https://github.com/hagezi/dns-blocklists"
- },
- "lightswitch05": {
- "url": "https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "XL",
- "focus": "compilation",
- "descurl": "https://github.com/lightswitch05/hosts"
- },
- "notracking": {
- "url": "https://raw.githubusercontent.com/notracking/hosts-blocklists/master/dnscrypt-proxy/dnscrypt-proxy.blacklist.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XL",
- "focus": "tracking",
- "descurl": "https://github.com/notracking/hosts-blocklists"
- },
- "oisd_big": {
- "url": "https://big.oisd.nl/domainswild2",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XXL",
- "focus": "general",
- "descurl": "https://oisd.nl"
- },
- "oisd_nsfw": {
- "url": "https://nsfw.oisd.nl/domainswild2",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "XXL",
- "focus": "porn",
- "descurl": "https://oisd.nl"
- },
- "oisd_nsfw_small": {
- "url": "https://nsfw-small.oisd.nl/domainswild2",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "M",
- "focus": "porn",
- "descurl": "https://oisd.nl"
- },
- "oisd_small": {
- "url": "https://small.oisd.nl/domainswild2",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "L",
- "focus": "general",
- "descurl": "https://oisd.nl"
- },
- "openphish": {
- "url": "https://openphish.com/feed.txt",
- "rule": "BEGIN{FS=\"\/\"}/^http[s]?:\\/\\/([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+(\\/|$)/{print tolower($3)}",
- "size": "S",
- "focus": "phishing",
- "descurl": "https://openphish.com"
- },
- "phishing_army": {
- "url": "https://phishing.army/download/phishing_army_blocklist_extended.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "phishing",
- "descurl": "https://phishing.army"
- },
- "reg_cn": {
- "url": "https://easylist-downloads.adblockplus.org/easylistchina.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_china",
- "descurl": "https://easylist.to"
- },
- "reg_cz": {
- "url": "https://easylist-downloads.adblockplus.org/easylistczechslovak.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_czech+slovak",
- "descurl": "https://easylist.to"
- },
- "reg_de": {
- "url": "https://easylist-downloads.adblockplus.org/easylistgermany.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_germany",
- "descurl": "https://easylist.to"
- },
- "reg_es": {
- "url": "https://easylist-downloads.adblockplus.org/easylistspanish.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_spain",
- "descurl": "https://easylist.to"
- },
- "reg_fi": {
- "url": "https://raw.githubusercontent.com/finnish-easylist-addition/finnish-easylist-addition/master/Finland_adb.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_finland",
- "descurl": "https://github.com/finnish-easylist-addition"
- },
- "reg_fr": {
- "url": "https://easylist-downloads.adblockplus.org/liste_fr.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "M",
- "focus": "reg_france",
- "descurl": "https://forums.lanik.us/viewforum.php?f=91"
- },
- "reg_id": {
- "url": "https://easylist-downloads.adblockplus.org/abpindo.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_indonesia",
- "descurl": "https://easylist.to"
- },
- "reg_it": {
- "url": "https://easylist-downloads.adblockplus.org/easylistitaly.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_italy",
- "descurl": "https://easylist.to"
- },
- "reg_jp": {
- "url": "https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_japan",
- "descurl": "https://github.com/k2jp/abp-japanese-filters"
- },
- "reg_kr": {
- "url": "https://raw.githubusercontent.com/List-KR/List-KR/master/filters-share/adservice.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_korea",
- "descurl": "https://github.com/List-KR/List-KR"
- },
- "reg_lt": {
- "url": "https://easylist-downloads.adblockplus.org/easylistlithuania.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_lithuania",
- "descurl": "https://easylist.to"
- },
- "reg_nl": {
- "url": "https://easylist-downloads.adblockplus.org/easylistdutch.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_netherlands",
- "descurl": "https://easylist.to"
- },
- "reg_pl": {
- "url": "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "M",
- "focus": "reg_poland",
- "descurl": "https://kadantiscam.netlify.app"
- },
- "reg_ro": {
- "url": "https://easylist-downloads.adblockplus.org/rolist.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_romania",
- "descurl": "https://easylist.to"
- },
- "reg_ru": {
- "url": "https://easylist-downloads.adblockplus.org/ruadlist.txt",
- "rule": "BEGIN{FS=\"[|^]\"}/^\\|\\|([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+\\^(\\$third-party)?$/{print tolower($3)}",
- "size": "S",
- "focus": "reg_russia",
- "descurl": "https://easylist.to"
- },
- "reg_se": {
- "url": "https://raw.githubusercontent.com/lassekongo83/Frellwits-filter-lists/master/Frellwits-Swedish-Hosts-File.txt",
- "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "reg_sweden",
- "descurl": "https://github.com/lassekongo83/Frellwits-filter-lists"
- },
- "reg_vn": {
- "url": "https://raw.githubusercontent.com/bigdargon/hostsVN/master/hosts",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "reg_vietnam",
- "descurl": "https://bigdargon.github.io/hostsVN"
- },
- "smarttv_tracking": {
- "url": "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "tracking",
- "descurl": "https://github.com/Perflyst/PiHoleBlocklist"
- },
- "spam404": {
- "url": "https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "general",
- "descurl": "https://github.com/Dawsey21"
- },
- "stevenblack": {
- "url": "https://raw.githubusercontent.com/StevenBlack/hosts/master/",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "VAR",
- "focus": "compilation",
- "descurl": "https://github.com/StevenBlack/hosts"
- },
- "stopforumspam": {
- "url": "https://www.stopforumspam.com/downloads/toxic_domains_whole.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "spam",
- "descurl": "https://www.stopforumspam.com"
- },
- "utcapitole": {
- "url": "https://dsi.ut-capitole.fr/blacklists/download/blacklists.tar.gz",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "VAR",
- "focus": "general",
- "descurl": "https://dsi.ut-capitole.fr/blacklists/index_en.php"
- },
- "wally3k": {
- "url": "https://v.firebog.net/hosts/static/w3kbl.txt",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "compilation",
- "descurl": "https://firebog.net/about"
- },
- "whocares": {
- "url": "https://someonewhocares.org/hosts/hosts",
- "rule": "/^127\\.0\\.0\\.1[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "M",
- "focus": "general",
- "descurl": "https://someonewhocares.org"
- },
- "winhelp": {
- "url": "https://winhelp2002.mvps.org/hosts.txt",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "general",
- "descurl": "https://winhelp2002.mvps.org"
- },
- "winspy": {
- "url": "https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt",
- "rule": "/^0\\.0\\.0\\.0[[:space:]]+([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($2)}",
- "size": "S",
- "focus": "win_telemetry",
- "descurl": "https://github.com/crazy-max/WindowsSpyBlocker"
- },
- "yoyo": {
- "url": "https://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext",
- "rule": "/^([[:alnum:]_-]{1,63}\\.)+[[:alpha:]]+([[:space:]]|$)/{print tolower($1)}",
- "size": "S",
- "focus": "general",
- "descurl": "https://pgl.yoyo.org/as"
- }
-}